Forum Discussion
Use List.Number to generate dates in a loop
- 3 years ago
Hi LoonaMoon ,
I would recommend looking for state holidays on your government's website and either scrape that or download from the endpoint.
For example, I'm in the UK and the GOV website has the following endpoint: https://www.gov.uk/bank-holidays.json
Using this, I just run the following query in a dataflow each night to have the most up-to-date listings:
let Source = Json.Document(Web.Contents("https://www.gov.uk/bank-holidays.json")), toList = Record.ToList(Source), toTable = Table.FromRecords(toList), expandEandWevents = toTable{0}[events], toTable2 = Table.FromList(expandEandWevents, Splitter.SplitByNothing(), null, null, ExtraValues.Error), expandRecords = Table.ExpandRecordColumn(toTable2, "Column1", {"title", "date", "notes", "bunting"}, {"title", "date", "notes", "bunting"}), remOthCols = Table.SelectColumns(expandRecords, {"date", "title", "notes"}), repQE2Funeral = Table.ReplaceValue(remOthCols, "Bank Holiday for the State Funeral of Queen Elizabeth II", "QE2 State Funeral BH", Replacer.ReplaceValue, {"title"}), repKC3Coronation = Table.ReplaceValue(repQE2Funeral, "Bank holiday for the coronation of King Charles III", "KC3 Coronation BH", Replacer.ReplaceValue, {"title"}), repBankHol1 = Table.ReplaceValue(repKC3Coronation, "bank holiday", "BH", Replacer.ReplaceText, {"title"}), repBankHol2 = Table.ReplaceValue(repBankHol1, "Bank Holiday", "BH", Replacer.ReplaceText, {"title"}), repBankHol3 = Table.ReplaceValue(repBankHol2, "Bank holiday", "BH", Replacer.ReplaceText, {"title"}), chgTypes = Table.TransformColumnTypes(repBankHol3,{{"title", type text}, {"date", type date}, {"notes", type text}}), renCols = Table.RenameColumns(chgTypes, {{"title", "holiday"}}) in renColsQuery output:
Pete
Hi LoonaMoon ,
I would recommend looking for state holidays on your government's website and either scrape that or download from the endpoint.
For example, I'm in the UK and the GOV website has the following endpoint: https://www.gov.uk/bank-holidays.json
Using this, I just run the following query in a dataflow each night to have the most up-to-date listings:
let
Source = Json.Document(Web.Contents("https://www.gov.uk/bank-holidays.json")),
toList = Record.ToList(Source),
toTable = Table.FromRecords(toList),
expandEandWevents = toTable{0}[events],
toTable2 = Table.FromList(expandEandWevents, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
expandRecords = Table.ExpandRecordColumn(toTable2, "Column1", {"title", "date", "notes", "bunting"}, {"title", "date", "notes", "bunting"}),
remOthCols = Table.SelectColumns(expandRecords, {"date", "title", "notes"}),
repQE2Funeral = Table.ReplaceValue(remOthCols, "Bank Holiday for the State Funeral of Queen Elizabeth II", "QE2 State Funeral BH", Replacer.ReplaceValue, {"title"}),
repKC3Coronation = Table.ReplaceValue(repQE2Funeral, "Bank holiday for the coronation of King Charles III", "KC3 Coronation BH", Replacer.ReplaceValue, {"title"}),
repBankHol1 = Table.ReplaceValue(repKC3Coronation, "bank holiday", "BH", Replacer.ReplaceText, {"title"}),
repBankHol2 = Table.ReplaceValue(repBankHol1, "Bank Holiday", "BH", Replacer.ReplaceText, {"title"}),
repBankHol3 = Table.ReplaceValue(repBankHol2, "Bank holiday", "BH", Replacer.ReplaceText, {"title"}),
chgTypes = Table.TransformColumnTypes(repBankHol3,{{"title", type text}, {"date", type date}, {"notes", type text}}),
renCols = Table.RenameColumns(chgTypes, {{"title", "holiday"}})
in
renCols
Query output:
Pete