March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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
)
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
122 | |
89 | |
74 | |
59 | |
53 |
User | Count |
---|---|
196 | |
120 | |
108 | |
68 | |
65 |