Forum Discussion
NourJ
Helper III
3 years agoSpecific Calendar conditions by DAX
I would like to generate a calendar table using DAX that is based on another column in my table.
My current table does not contain a date or month column, but it does have a "Round" column that starts from 42 and goes up (42, 43, etc.).
I have established that Round 42 represents the months of May-June 2022 and Round 43 represents July-August 2022, and so on.
I want to create a calendar that automatically matches the months with the round numbers, rather than manually adding the dates to my reports.
Any advice?
Here's an example that shows one way to do it.
DatesRound = VAR startdate = DATE ( 2022, 5, 1 ) RETURN ADDCOLUMNS ( CALENDAR ( startdate, DATE ( 2023, 4, 30 ) ), "Round", 42 + ROUNDDOWN ( DATEDIFF ( startdate, [Date], MONTH ) / 2, 0 ) )Pat
1 Reply
- ppm1
Solution Sage
Here's an example that shows one way to do it.
DatesRound = VAR startdate = DATE ( 2022, 5, 1 ) RETURN ADDCOLUMNS ( CALENDAR ( startdate, DATE ( 2023, 4, 30 ) ), "Round", 42 + ROUNDDOWN ( DATEDIFF ( startdate, [Date], MONTH ) / 2, 0 ) )Pat