Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

DAX Help

Hi experts, below measure is giving wrong results in case of december month, please help

 

YEAR - MONTH  =
IF DAY('CALENDAR'[Date]) > 25 ,
CONCATENATE( YEAR('CALENDAR'[Date]) & "-" , MONTH('CALENDAR'[Date]) +1 ),
CONCATENATE( YEAR('CALENDAR'[Date]) & "-" , MONTH('CALENDAR'[Date]) )
)
 
Desired result =

25-11-2021 = 11-2021

26-11-2021 = 12-2021

 

25-12-2021 = 12-2021

26-12-2021 = 01-2022

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi

     

    Please try this

     

    YEAR - MONTH  =
    IF DAY('CALENDAR'[Date]) > 25 ,if(month('CALENDAR'[Date])<12,
    CONCATENATEYEAR('CALENDAR'[Date]"-" , MONTH('CALENDAR'[Date]) +1 ),
    CONCATENATEYEAR('CALENDAR'[Date]) & "-" , MONTH('CALENDAR'[Date]) )
    ))
    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous my requirement is different, 

       

      25-11-2021 = 11-2021

      26-11-2021 = 12-2021

       

      25-12-2021 = 12-2021

      26-12-2021 = 01-2022

      • Anonymous's avatar
        Anonymous
        Not applicable

        Anonymous  yes , It will work. wondering why time intelligence is not working here. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Sorry


    This one should be ok

    YEAR - MONTH  =

    IF ( DAY('CALENDAR'[Date]) > 25 && MONTH('CALENDAR'[Date])=12,

    CONCATENATE( YEAR('CALENDAR'[Date])+1 & "-" , « 01 »),

    IF ( DAY('CALENDAR'[Date]) > 25 ,

    CONCATENATE( YEAR('CALENDAR'[Date]) & "-" , MONTH('CALENDAR'[Date])+1 ),

    CONCATENATE( YEAR('CALENDAR'[Date]) & "-" , MONTH('CALENDAR'[Date])))

  • Anonymous's avatar
    Anonymous
    Not applicable

    Sorry for late reply. Time to have diner here.

    Your time intelligence work for other calculation in your PBIX ?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

     

    Which time intelligence are you referring to, maybe there are other alternative functions

    If it doesn't work, it may also be related to the all() function inside. When the all() function is not used, at the day level we would always get one row from the calendar table, and when the all() function is used, the entire date table is returned.

    https://community.powerbi.com/t5/DAX-Commands-and-Tips/Time-intelligence-issues/m-p/1286680

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.