Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 Week =
IF ( ( WEEKNUM ( NOW (), 2 ) - 1 ) = Calendar[Week Number], TRUE, FALSE )
Current Week =
IF ( ( WEEKNUM ( NOW (), 2 ) - 0 ) = 'Calendar'[Week Number], TRUE, FALSE )
This works fine but I would however like that I have just 1 column, where I have the text "Current Week" and "Previous Week" for the appropriate weeks and then the week numbers in the rest of the column. I'm unsure how to do this though.
Could someone please advise me?
Thanks.
Solved! Go to Solution.
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]), "#")
)
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]), "#")
)
I think this will do what you are looking for.
Week Column =
VAR _DateWeek = [Date] - WEEKDAY ( [Date] )
VAR _Today = TODAY()
VAR _ThisWeek = _Today - WEEKDAY( _Today )
VAR _LastWeek = _Today - WEEKDAY( _Today ) - 7
RETURN
SWITCH(
TRUE(),
_DateWeek = _ThisWeek, "Current Week",
_DateWeek = _LastWeek, "Last Week",
FORMAT( WEEKNUM([Date]), "#")
)
Thank you, my week starts on Monday though. How do I change this?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 67 | |
| 62 |