Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
lcap
New 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.  

1 ACCEPTED SOLUTION

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" )




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

9 REPLIES 9
v-yalanwu-msft
Community Support
Community Support

Hi, @lcap ;

If it is less than the end of the current month:

7 Reactive Report Before Current Month? =
IF ( [Case Reported On] <= EOMONTH ( TODAY (), 0 ), "Yes", "No" )

If it is less than the start of the current month:

7 Reactive Report Before Current Month? =
IF ( [Case Reported On] <= EOMONTH ( TODAY (), -1 ), "Yes", "No" )


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PaulDBrown
Community Champion
Community Champion

for current month use

MONTH(TODAY()) && YEAR(TODAY())

 

So if have a date table, the expression would be

... 'Date Table'[Month] = MONTH(TODAY()) && 'Date Table'[Year] = YEAR(TODAY())





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Like this?

7 Reactive Report Before Current Month? = IF([Case Reported On]<MONTH(TODAY()) && YEAR(TODAY(),"Yes","No")

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?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






[Case reported on]  is a date field.

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"
)

prev month.png

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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")

THank you so much.

 

Is there a simple way to use an IF statement to say wether its in the current month?

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" )




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.