Forum Discussion

gmasta1129's avatar
gmasta1129
Resolver I
4 years ago
Solved

Month End Data_% Change

Hello,    I am trying to calculate the % change month over month (month end/last day of month).     **Please note the run date is first day of month because our data is on a 1 day lag.  Is it pos...
  • TomMartens's avatar
    4 years ago

    Hey gmasta1129 ,

     

    I have to admit that I do not fully understand why it's necessary to calculate the MoM change based on the Month's end date.
    Nevertheless, my sample data looks like this:

    The I use the below 2 DAX statements to create calculated columns, one returns the month end date of the current month based on Run Date 2 value and the other returns end of month of the previous month.

    End Of Month = 
    EOMONTH( 'Table'[Run Date 2] , 0 ) 

     

    End Of Prev Month = 
    EOMONTH( 'Table'[Run Date 2] , -1 ) 

    Then my table looks like this:

    Finally, I use the below DAX statement to create a calculated column that returns the MoM change:

    MoM change = 
    var prevMonthValue = LOOKUPVALUE('Table'[Utilization_Overlall] ,'Table'[End Of Month] , 'Table'[End Of Prev Month] )
    return
    if( isblank(prevMonthValue )
        , BLANK()
        , ( divide( 'Table'[Utilization_Overlall] , prevMonthValue ) - 1 ) * 100
    )

    I recommend, reading this article Time patterns – DAX Patterns, the article provides almost everything for date-based calculations, and also explains why using a dedicated calendar table is so important.

     

    Regards,

    Tom