let // Paste your SRA Primary subscription key below ApiKey = "6503872f1e8b45458546c41bbf390264", // Call the SRA GetAllOrganisations API Source = Json.Document( Web.Contents( "https://sra-prod-apim.azure-api.net", [ RelativePath = "datashare/api/V1/organisation/GetAll", Headers = [ #"Ocp-Apim-Subscription-Key" = ApiKey, #"Cache-Control" = "no-cache" ] ] ) ), // Extract the Organisations array Organisations = Source[Organisations], // Convert all organisations into an Excel-style table Firms = Table.FromRecords(Organisations), // Convert AuthorisationDate to a proper date ConvertedDates = Table.TransformColumns( Firms, { { "AuthorisationDate", each try Date.From(DateTimeZone.FromText(_)) otherwise try Date.From(DateTime.FromText(_)) otherwise try Date.FromText(_) otherwise null, type date } } ), // Keep firms authorised during the last 5 years LastFiveYears = Table.SelectRows( ConvertedDates, each [AuthorisationDate] <> null and [AuthorisationDate] >= #date(2021, 9, 10) and [AuthorisationDate] <= #date(2026, 9, 10) ), // Add year for easy filtering in Excel AddedYear = Table.AddColumn( LastFiveYears, "AuthorisationYear", each Date.Year([AuthorisationDate]), Int64.Type ), // Put newest firms first Sorted = Table.Sort( AddedYear, {{"AuthorisationDate", Order.Descending}} ) in Sorted