Forum Discussion

lucie_raboch's avatar
lucie_raboch
Helper II
1 year ago
Solved

Calendar with condition

Hi all,

I have Calendar created like the below:

 

DimDates =
VAR BaseCalendar =
        CALENDAR(DATE(2023,1,2), TODAY())
RETURN
        GENERATE(
            BaseCalendar,
            VAR BaseDate = [Date]
            VAR YearDate = YEAR(BaseDate)
            VAR Week = WEEKNUM(BaseDate,21)
            RETURN
            ROW (
                "Year",YearDate,
                "YearMonth",FORMAT(BaseDate,"yyyy-mm"),
                "YearWeeknumber", FORMAT(BaseDate,"yyyy") &"-"& FORMAT(WEEKNUM (BaseDate,21),"00"),
                "Weeknumber", "W" &"-"& FORMAT(WEEKNUM (BaseDate,21),"00")
                               
            )    
    )
 

 

Basically nothing special, but as you can see I'm using format week = 21 means that year 2025 starting 2024-12-30. I need to change column Year for 2024-12-30 and 2024-12-31 to be Year 2025 and not 2024. Only these two dates are wrong. Is there any special format for year? 

Maybe put some conditions into calendar DAX?

Thank you for your help.

 

  • Calendars are immutable. There is no point in doing this in either DAX or Power Query  (apart from a nice finger exercise).  Use an external reference table that has all the required quirks precomputed.

1 Reply

  • Calendars are immutable. There is no point in doing this in either DAX or Power Query  (apart from a nice finger exercise).  Use an external reference table that has all the required quirks precomputed.