Forum Discussion

lcap's avatar
lcap
New Member
3 years ago
Solved

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.  

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

9 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    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's avatar
    PaulDBrown
    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())

    • LYeo87's avatar
      LYeo87
      Helper II

      Like this?

      7 Reactive Report Before Current Month? = IF([Case Reported On]<MONTH(TODAY()) && YEAR(TODAY(),"Yes","No")
      • PaulDBrown's avatar
        PaulDBrown
        Community 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?