Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello, everyone! Hope somebody could help me out.
I need a Monthyear slicer for a page but I wanted it to be dynamic in a way that the reader doesn't have to filter the slicer every time it's a new month - so this is like creating a default TODAY slicer date.
Currently, I have this calculated column in my Calendar table:
As of Month =
VAR _today = TODAY()
RETURN
IF (
(
( YEAR ( _today ) * 100 )
+ MONTH ( _today )
)
= (
( YEAR ( 'Calendar'[Date] ) * 100 )
+ MONTH ( 'Calendar'[Date] )
),
"Filtered Month",
CONVERT (
( YEAR ( 'Calendar'[Date] ) * 100 )
+ MONTH ( 'Calendar'[Date] ),
STRING
)
)
and what it basically does is if the Date column falls within the current YearMonth, then show as " Filtered Month". Else, show the YearMonth as is.
Now, this is how my Calculated Column looks in the slicer:
My problem now is: I need to modify my DAX in a way that:
If the current date is Day 1 of the month, then it should treat the current date as previous day (Ex. If today is June 1, then it should treat today as if it's May 31 so that the calendar dates with 202205 will be classified as "Filtered Month". However, if it's not Day 1, say June 2, then it should treat today as current date and so the calendar dates with 202206 will be classified as "Filtered Month".)
Solved! Go to Solution.
I was able to modify it this way:
As of Month =
VAR _actualtoday = TODAY()
VAR _today = if(DAY(_actualtoday)=1,EOMONTH(_actualtoday,-1),_actualtoday)
RETURN
IF (
(
( YEAR ( _today ) * 100 )
+ MONTH ( _today )
)
= (
( YEAR ( 'Calendar'[Date] ) * 100 )
+ MONTH ( 'Calendar'[Date] )
),
"Filtered Month",
CONVERT (
( YEAR ( 'Calendar'[Date] ) * 100 )
+ MONTH ( 'Calendar'[Date] ),
STRING
)
)
I was able to modify it this way:
As of Month =
VAR _actualtoday = TODAY()
VAR _today = if(DAY(_actualtoday)=1,EOMONTH(_actualtoday,-1),_actualtoday)
RETURN
IF (
(
( YEAR ( _today ) * 100 )
+ MONTH ( _today )
)
= (
( YEAR ( 'Calendar'[Date] ) * 100 )
+ MONTH ( 'Calendar'[Date] )
),
"Filtered Month",
CONVERT (
( YEAR ( 'Calendar'[Date] ) * 100 )
+ MONTH ( 'Calendar'[Date] ),
STRING
)
)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
80 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |