Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Current Month - DAX

 
 

I have a table with 3 years of Data and am writing a dax to get the Current month but somehow it's looking at the past current month as well. What's wrong?

 

= if Date.MonthName( DateTime.LocalNow() ) = Date.MonthName([Date]) then "Current Month" else Date.MonthName([Date])

 

How can I exclude past year/past month

 

 

  • You can adapt your code like this

     

    = if Date.MonthName( DateTime.LocalNow() ) = Date.MonthName([Date]) and Date.Year( DateTime.LocalNow() ) = Date.Year([Date]) then "Current Month" else Date.MonthName([Date])

     

    Pat

     

2 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    You can adapt your code like this

     

    = if Date.MonthName( DateTime.LocalNow() ) = Date.MonthName([Date]) and Date.Year( DateTime.LocalNow() ) = Date.Year([Date]) then "Current Month" else Date.MonthName([Date])

     

    Pat

     

    • Anonymous's avatar
      Anonymous
      Not applicable
       

      Thanks, It Worked!