Created
May 3, 2023 15:49
-
-
Save bjulius/70025ffbfc33e6611e8ba0ef520dd2cc to your computer and use it in GitHub Desktop.
Brian Julius M Code to Create Dynamic Holiday Table from Nager.at Public API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
fnHolidayTable = (StartYear as number, EndYear as number, ISO2Code as text) as table => | |
let | |
YearList = List.Numbers(StartYear, EndYear - StartYear + 1), | |
YearTable = Table.FromList( | |
YearList, | |
Splitter.SplitByNothing(), | |
{"HolYear"}, | |
null, | |
ExtraValues.Error | |
), | |
APIColumn = Table.AddColumn( | |
YearTable, | |
"API", | |
each Web.Contents( | |
"https://date.nager.at/api/v3/publicholidays/" & Text.From([HolYear]) & "/" & ISO2Code | |
) | |
), | |
FilterHidden = Table.SelectRows(APIColumn, each [Attributes]?[Hidden]? <> true), | |
InvokeCustom = Table.AddColumn(FilterHidden, "Transform File", each #"Transform File"([API])), | |
RemoveOtherCols = Table.SelectColumns(InvokeCustom, {"Transform File"}), | |
Expand = Table.ExpandTableColumn(RemoveOtherCols, "Transform File", {"date", "localName", "name", "countryCode", "fixed", "global", "counties", "launchYear", "types.0"}, {"date", "localName", "name", "countryCode", "fixed", "global", "counties", "launchYear", "types.0"}), | |
RemoveCols = Table.RemoveColumns(Expand,{"localName", "fixed", "global", "counties", "launchYear"}), | |
ChangeType = Table.RenameColumns( Table.TransformColumnTypes(RemoveCols,{{"date", type date}}), {"date", "holidayDate"}) | |
in | |
ChangeType | |
in | |
fnHolidayTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment