daxutilization

DAX WeekNum for more than 1-year?


I have a Calendar table that has 3 DAX columns:

Column 1: Calendar = CALENDAR(DATE(2018,1,1), TODAY())

Column 2(This is used to set 8 hours of work unless it's weekend or holiday(40 hours/week by default)):

DayHours = 
    VAR Hols =
        RELATED ( Holidays[Date] )
    VAR WKD =
        WEEKDAY ( 'Calendar'[Date] )
RETURN
     IF ( WKD >= 2 && WKD <= 6 && Hols <> 'Calendar'[Date], 8, 0 )    

Column 3: WeekNum = WEEKNUM('Calendar'[Date])

Image: https://i.sstatic.net/eLlap.jpg

With that, I calculate Utilization % both Billable and Non-Billable in a Matrix were the Columns are the WeekNum, everything was well until 2019 now the Matrix is summing the WeekNumbers that we already passed in 2019 (1,2 and 3) with the same from 2018 giving me usually 80 hours/week w/o holidays.

The solution I see is for the WeekNum to show the Year too, like 1-2018, 1-2019, but I don't see how to do that.

Any thoughts on how to solve that?

Regards,


Solution

  • You could concatenate your YEAR() and WEEKNUM() results in a single column like this:

    WeekNum =
    CONCATENATE ( WEEKNUM ( 'Calendar'[Date] ), YEAR ( 'Calendar'[Date] ) )
    

    Which would appear as 12018. If you wanted to add the dash (1-2018) you could add another concatenate:

    WeekNum =
    CONCATENATE (
        WEEKNUM ( 'Calendar'[Date] ),
        CONCATENATE ( " - ", YEAR ( 'Calendar'[Date] ) )
    )