Forum Discussion

Niels_T's avatar
Niels_T
Post Patron
4 years ago
Solved

Dynamic month only for current year

I have the following DAX:

Dynamic Month = MONTH(EOMONTH(TODAY(),0))-MONTH(EOMONTH(MAX('Calendar'[Date])

 

I would like to have my dynamic month only applied to the current year so that in 2023 (in this case April) the value will be blank: 

 

What I've tried so far 

Dynamic Month = IF(YEAR(TODAY()), MONTH(EOMONTH(TODAY(),0))-MONTH(EOMONTH(MAX('Calendar'[Date]),blank()))).
 
However this gives me the same result.

 

  • Niels_T 
    Your condiion IF(YEAR(TODAY()) always return true 🙂
    You need something like:
    IF(YEAR(TODAY())= YEAR(MAX(Calendar'[Date]), ...

2 Replies

  • SpartaBI's avatar
    SpartaBI
    Community Champion

    Niels_T 
    Your condiion IF(YEAR(TODAY()) always return true 🙂
    You need something like:
    IF(YEAR(TODAY())= YEAR(MAX(Calendar'[Date]), ...

  • Hi,

    I am not sure if I understood your question correctly, but please try the below measure.

     

    Dynamic Month =
    (
        MONTH ( EOMONTH ( TODAY (), 0 ) )
            - MONTH ( EOMONTH ( MAX ( 'Calendar'[Date] ), 0 ) )
    )
        * DIVIDE (
            VAR _condition =
                MAX ( YEAR ( Calendar[Date] ) ) = YEAR ( TODAY () )
            RETURN
                _condition,
            _condition
        )