DAX | Week-to-Date (WTD) - 1

PHOTO EMBED

Sat Dec 30 2023 07:02:06 GMT+0000 (Coordinated Universal Time)

Saved by @nikahafiz #ms.pbi #dax #dax.var #dax.return #week.to.date-wtd #dax.lastdate #dax.max #dax.weekday #dax.calculate #dax.datesbetween #dax.dateadd

Sales-WTD = 

VAR CD =
    LASTDATE( 'Calendar'[Date] )

VAR CY =
    MAX( 'Calendar'[Year] )
    
VAR WeekDayNo =
    WEEKDAY( LASTDATE( 'Calendar'[Date] ), 3 )

RETURN
CALCULATE(
    [Total Sales],
    DATESBETWEEN(
        'Calendar'[Date],
        DATEADD(
            CD, 
            -1 * WeekDayNo, DAY ), 
            CD),
    'Calendar'[Year] = CY
)
content_copyCOPY