Forum Discussion
Month End Data_% Change
- 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
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