Forum Discussion
Anonymous
5 years agoNot applicable
Level Of Detail Expression
Does anyone know how to implement the formula of LOD in Tableau into Power BI (DAX)? Formula: if [Last Update Date] = { FIXED : MAX([Last Update Date])} then "Current Week" elseif [Last Update ...
- 5 years ago
Hi Anonymous ,
Try following:
base data:
Measure:
week = IF ( WEEKNUM ( ( MAX ( 'Table'[Date] ) ) ) = WEEKNUM ( TODAY () ), "Current Week", IF ( WEEKNUM ( ( MAX ( 'Table'[Date] ) ) ) = WEEKNUM ( TODAY () ) - 1, "Previous Week", "null" ) )Final get:
And if you not want to get a measure,but rather to new column,use the following dax:
week2 = IF ( WEEKNUM ( ( 'Table'[Date] ) ) = WEEKNUM ( TODAY () ), "Current Week", IF ( WEEKNUM ( ( 'Table'[Date] ) ) = WEEKNUM ( TODAY () ) - 1, "Previous Week", "null" ) )tip:
WEEKNUM([date],1) - the first week of the year, 1 means counting from Sunday, 2 means counting from Monday,adjust as you need!
Wish it is helpful for you!
Best Regards
Lucien
v-luwang-msft
5 years agoCommunity Support
Hi Anonymous ,
Try following:
base data:
Measure:
week =
IF (
WEEKNUM ( ( MAX ( 'Table'[Date] ) ) ) = WEEKNUM ( TODAY () ),
"Current Week",
IF (
WEEKNUM ( ( MAX ( 'Table'[Date] ) ) )
= WEEKNUM ( TODAY () ) - 1,
"Previous Week",
"null"
)
)
Final get:
And if you not want to get a measure,but rather to new column,use the following dax:
week2 =
IF (
WEEKNUM ( ( 'Table'[Date] ) ) = WEEKNUM ( TODAY () ),
"Current Week",
IF (
WEEKNUM ( ( 'Table'[Date] ) )
= WEEKNUM ( TODAY () ) - 1,
"Previous Week",
"null"
)
)
tip:
WEEKNUM([date],1) - the first week of the year, 1 means counting from Sunday, 2 means counting from Monday,adjust as you need!
Wish it is helpful for you!
Best Regards
Lucien