Forum Discussion
lcap
3 years agoNew Member
DAX 'Current Month'
Hiya, I'm struggling to work out how to formulate a column with an IF statement - i'm stuck how to express Current Month. Thanks in advance.
- 3 years ago
Try:
Before current month = VAR _YMToday = YEAR ( TODAY () ) * 100 + MONTH ( TODAY () ) VAR _YMField = YEAR ( MAX ( 'Dates Table'[Date] ) ) * 100 + MONTH ( MAX ( 'Dates Table'[Date] ) ) RETURN IF ( _YMField = _YMToday, "Current month" )
PaulDBrown
3 years agoCommunity Champion
See my previous post: I edited it to be more precise....
7 Reactive Report Before Current Month? = IF([Case Reported On]<MONTH(TODAY()) && YEAR(TODAY(),"Yes","No")
You need to compare a month field with MONTH(TODAY()) and a year field with YEAR(TODAY()).
What is your [Case reported on] measure returning?
LYeo87
3 years agoHelper II
[Case reported on] is a date field.
- PaulDBrown3 years agoCommunity Champion
Actually the code I posted will not return previous dates in previous years which are > MONTH (TODAY()).
So you can either use:
Before current month = VAR _YMToday = YEAR(TODAY()) * 100 + MONTH(TODAY()) VAR _YMField = YEAR(MAX('Dates Table'[Date])) * 100 + MONTH(MAX('Dates Table'[Date])) RETURN IF(_YMField < _YMToday, "Previous")or
Alternative = IF ( MAX ( 'Dates Table'[Date] ) < STARTOFMONTH ( FILTER ( ALL ( 'Dates Table'[Date] ), 'Dates Table'[Date] = TODAY () ) ), "Alternative" ) - LYeo873 years agoHelper II
I already have a similar column which is working fine -
6 Reactive Report Before 2 Days Ago? = IF([Case Reported On]<TODAY()-2,"Yes","No")- LYeo873 years agoHelper II
THank you so much.
Is there a simple way to use an IF statement to say wether its in the current month?
- PaulDBrown3 years agoCommunity Champion
Try:
Before current month = VAR _YMToday = YEAR ( TODAY () ) * 100 + MONTH ( TODAY () ) VAR _YMField = YEAR ( MAX ( 'Dates Table'[Date] ) ) * 100 + MONTH ( MAX ( 'Dates Table'[Date] ) ) RETURN IF ( _YMField = _YMToday, "Current month" )