Hi John,
I’ll let someone else answer the part about setting the date table to the beginning of the year for the minimum date in a specific date, although my next point sort of answers it (potentially).
When you use this awesome date table, and you are in the function to set the dates, I find the minimum date I need for the starting date as this “usually” does not change so there is no need to make it dynamic if it doesn’t need to be. So I will enter the start date of my date table as 01/01/2022 and the end date as 31/12/2022 (end date is a placeholder just now).
With regards to the end date of your date table, this needs to be dynamic.
I will create a blank query and place the below M Code into it
let
Source = Date.EndOfYear(List.Max(#"Your Table Name"[Date]))
in
Source
I’ve called this query DateEnd. In my case it will find the last date in my table I want the date table to be connected to…and through using Date.EndOfYear combined with List.Max it will dynamically update to the final day of the year as your data date range grows, making my date table dynamic. So as soon as you have a value that ticks over to 2023, then the date table will expand all the way until the end of 2023.
List.Max finds the last value, in this case, the last/oldest date in the date column you wish to use as the reference for your date table.
Date.EndOfYear simply finds the last day of the calendar year from the List.Max value.
I then go to my actual date table, into the Advanced Editor, and update my date table by entering DateEnd instead of an actual hard coded date. This will make your date table dynamic. as per below
let
Source = fxDate(#date(2020, 1, 1), DateEnd, null, null, null),
Usually, I’d hardcode the start date of the date table as you don’t want to run a dynamic query on the start date if you don’t need to.
DJ