Dynamically control range of years in Date table

generalledger

New member
Joined
Oct 15, 2016
Messages
10
Reaction score
0
Points
0
Location
New Jersey, USA
Excel Version(s)
2016
I am trying to dynamically control the range of years in my Date table. I currently have:

= Table.SelectRows(dbo_DateDimensionT, each [YearKey] >= 2013 and [YearKey] <= 2019)

I want the YearKey to be greater than or equal to the minimum year of dates in the column [Date] of the table PeriodDates that is in Power Query.

Also, the YearKey to be less than or equal to the maximum year of dates in the column [Date] of the table PeriodDates that is in Power Query.

It seems the solution should look something like:

= Table.SelectRows(dbo_DateDimensionT, each [YearKey] >= Year(Min(PeriodDates[Date])) and [YearKey] <= Year(Max(PeriodDates[Date]))

Of course this fails.

Thank you!!!
 
To get the min and max year of column Date in table PeriodDates you'd reference the variables like this

Code:
YMax=Date.Year(List.Max(PeriodDates[Date])),
YMin=Date.Year(List.Min(PeriodDates[Date])),
Table.SelectRows(dbo_DateDimensionT, each [YearKey] >=  YMin and [YearKey] <= YMax)
 
Good genes and good jeans
 
Back
Top