Forum Discussion
Measure evolution between periods
Hello,
I am trying to measure an evolution between the scores of previous period and last period. The following expression works:
Thank you for your response.
I can indeed create a date column out of the period column. However, if I use the expression below, I don't indicate that month 1 needs to use only the last period.
_Final = Var Month1 = AVERAGE('Table'[Column1]) Var Month2 = CALCULATE(AVERAGE('Table'[Column1]),PARALLELPERIOD('Table'[Date],-1,MONTH)) RETURN (Month1-Month2) /100I tried to use the expression below, but that did not work.
Var Month1 = CALCULATE(AVERAGE(PSScoreHist[Score]),PARALLELPERIOD(PSScoreHist[Month],0,MONTH))- Anonymous5 years ago
Hi nele ,
You can update the formula of your measure [Development] as below:
Development = VAR _lastperiod = CALCULATE ( MAX ( PSScoreHist[Period] ), ALLSELECTED ( PSScoreHist ) ) VAR _preperiod = CALCULATE ( MAX ( PSScoreHist[Period] ), FILTER ( ALLSELECTED ( PSScoreHist ), PSScoreHist[Period] < _lastperiod ) ) RETURN ( CALCULATE ( AVERAGE ( PSScoreHist[Score] ), PSScoreHist[Period] = _lastperiod ) - CALCULATE ( AVERAGE ( PSScoreHist[Score] ), PSScoreHist[Period] = _preperiod ) ) / 100Best Regards
8 Replies
- FarhanAhmed
Community Champion
If you are having consistent data in Period then you should create a Date column out of it and change the new column data type to date
Date = LEFT(PSScoreHist[Period],4) & "-" & RIGHT(PSScoreHist[Period],2) &"-01"Once this is done now you can use below to create Average Variance (Replace appropriate column)
_Final = Var Month1 = AVERAGE('Table'[Column1]) Var Month2 = CALCULATE(AVERAGE('Table'[Column1]),PARALLELPERIOD('Table'[Date],-1,MONTH)) RETURN (Month1-Month2) /100 - neleFrequent Visitor
Thank you for your response.
I can indeed create a date column out of the period column. However, if I use the expression below, I don't indicate that month 1 needs to use only the last period.
_Final = Var Month1 = AVERAGE('Table'[Column1]) Var Month2 = CALCULATE(AVERAGE('Table'[Column1]),PARALLELPERIOD('Table'[Date],-1,MONTH)) RETURN (Month1-Month2) /100I tried to use the expression below, but that did not work.
Var Month1 = CALCULATE(AVERAGE(PSScoreHist[Score]),PARALLELPERIOD(PSScoreHist[Month],0,MONTH))- FarhanAhmed
Community Champion
In the Above DAX , Month1 is your current Month which is selected through your filter.
Month2 is preceeding month which in your case if you select July in filter then Month1 is July and Month2 is June.
CALCULATE(AVERAGE(PSScoreHist[Score]),PARALLELPERIOD(PSScoreHist[Month],0,MONTH)) will give you same result as your AVERAGE('Table'[Column1])
- neleFrequent Visitor
Is it possible to just use the last period in the DAX? I don't want to use a filter. Only the evolution from last month until this month is relevant.
- AnonymousNot applicable
Hi nele ,
You can update the formula of your measure [Development] as below:
Development = VAR _lastperiod = CALCULATE ( MAX ( PSScoreHist[Period] ), ALLSELECTED ( PSScoreHist ) ) VAR _preperiod = CALCULATE ( MAX ( PSScoreHist[Period] ), FILTER ( ALLSELECTED ( PSScoreHist ), PSScoreHist[Period] < _lastperiod ) ) RETURN ( CALCULATE ( AVERAGE ( PSScoreHist[Score] ), PSScoreHist[Period] = _lastperiod ) - CALCULATE ( AVERAGE ( PSScoreHist[Score] ), PSScoreHist[Period] = _preperiod ) ) / 100Best Regards
- neleFrequent Visitor
Hi Yingyinr,
your solution works perfectly! Thank you so much for your support!