Forum Discussion

TomJ54545's avatar
TomJ54545
New Member
4 years ago
Solved

Write current and previous week in a date table

Hi,    I have a date table where I have 2 columns, 1 for previous week and the same for the current week, where I get the true/false values. The DAX for the columns is as follows:    Previous We...
  • jdbuchanan71's avatar
    4 years ago

    Like this.

    Week = 
    VAR _DateWeek = [Date] - WEEKDAY ( [Date], 2 )
    VAR _Today = TODAY()
    VAR _ThisWeek = _Today - WEEKDAY( _Today, 2 )
    VAR _LastWeek = _Today - WEEKDAY( _Today, 2 ) - 7
    RETURN
    SWITCH(
        TRUE(),
        _DateWeek = _ThisWeek, "Current Week",
        _DateWeek = _LastWeek, "Last Week",
        FORMAT(  WEEKNUM([Date]), "#")
    )