Forum Discussion
bleow
5 years agoFrequent Visitor
Generating date table by year
I need to generate a date table like the following: calendar year start calendar year end 1/1/2021 12/12/2021 1/1/2020 12/12/2020 1/1/2019 12/12/2019 The number of rows is ref...
- Anonymous5 years ago
Hi bleow,
Did you mean to use the current date and the range to generate a table with the start date and end date?
If that is the case, you can take a look at the following formula:
let offset = 4, Source = List.Transform( List.Numbers( Date.Year(DateTime.LocalNow()) - offset + 1, offset ), each Text.From(_) & "," & Text.From(#date(_, 1, 1)) & "," & Text.From(#date(_, 12, 31)) ), #"Converted to Table" = Table.FromList( Source, Splitter.SplitTextByDelimiter(","), null, null, ExtraValues.Error ), #"Renamed Columns" = Table.RenameColumns( #"Converted to Table", { { "Column1", "Year" }, { "Column2", "Start" }, { "Column3", "End" } } ), #"Changed Type" = Table.TransformColumnTypes( #"Renamed Columns", { { "Year", Int64.Type }, { "Start", type date }, { "End", type date } } ) in #"Changed Type"Regards,
Xiaoxin Sheng
Anonymous
5 years agoNot applicable
Please explain exactly the logic behind the calculations.