Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hi there,
I have questions about getting the previous value at Table in order to calculate the change by percentage.
All fields at from the same table -STAGERAW. For Average of Days in Stage, I use the TOTALYDAYSINSTAGE column, data type is whole number and select "average".
I hope to get the change by stagename. For example, Authorise NIL Memebers percentage change:
month_year pct_change
2 = (18.13 - 1)/1
3 = (9.5 - 18.13) / 18.13
I've tried OFFSET and EARLIER but it shows (STAGERAW) Previous Value: EARLIER/EARLIST refers to an earlier row context which doesn't exist for both DAX.
method 1:
method 2:
Solved! Go to Solution.
Hi @Anonymous
Please try this:
I create a set of sample:
Then create a measure:
Measure =
VAR _currentmonth = MAX('Table'[Month_Year])
VAR _currentdata = CALCULATE(
AVERAGE('Table'[TOTALYDAYSINSTAGE]),
'Table'[Month_Year] = _currentmonth
)
VAR _previousmonth = CALCULATE(
MAX('Table'[Month_Year]),
FILTER(
ALLSELECTED('Table'),
'Table'[Month_Year] < _currentmonth
)
)
VAR _previousdata = CALCULATE(
AVERAGE('Table'[TOTALYDAYSINSTAGE]),
'Table'[Month_Year] = _previousmonth
)
RETURN
IF(
_previousmonth <> BLANK(),
(_currentdata - _previousdata) / _previousdata
)
The result is as follow:
Best Regards,
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Please try this:
I create a set of sample:
Then create a measure:
Measure =
VAR _currentmonth = MAX('Table'[Month_Year])
VAR _currentdata = CALCULATE(
AVERAGE('Table'[TOTALYDAYSINSTAGE]),
'Table'[Month_Year] = _currentmonth
)
VAR _previousmonth = CALCULATE(
MAX('Table'[Month_Year]),
FILTER(
ALLSELECTED('Table'),
'Table'[Month_Year] < _currentmonth
)
)
VAR _previousdata = CALCULATE(
AVERAGE('Table'[TOTALYDAYSINSTAGE]),
'Table'[Month_Year] = _previousmonth
)
RETURN
IF(
_previousmonth <> BLANK(),
(_currentdata - _previousdata) / _previousdata
)
The result is as follow:
Best Regards,
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
it works correctly! i change the RETURN to _previousdata and get the below correct previous value:
can i ask about the operation process for this DAX?
thank you for the solution. I have tried the measure as below:
hi @Anonymous ,
Please confirm that combination of STAGENAME and BEREAVEMENTRAW.BEREVEMENT_MONTH_NUMBER is unique.
If possible please share pbix file with all sensitive data removed.
Hi Talespin,
I hope to attach the pbix file but it shows .pbix is not supported. where can i attach file?
Meanwhile, shall i use concatenatex to combination STAGENAME and BEREAVEMENTRAW.BEREVEMENT_MONTH_NUMBER to create unique value?
Many thanks,
Jessie
Hi @Anonymous ,
"Meanwhile, shall i use concatenatex to combination STAGENAME and BEREAVEMENTRAW.BEREVEMENT_MONTH_NUMBER to create unique value?"
No, please don't do that
Please try this and test results. I assumed the combination of STAGENAME and MONTH is unique, but it is clear that you are taking average for DAYSINSTAGE. Sorry for that.
the measure works but it doesn't pull the previous value.
I change the RETURN to previousVal and please find the screenshot as reference.
hi @Anonymous
Sharing both calculated column and measure
User | Count |
---|---|
11 | |
9 | |
6 | |
5 | |
4 |