Forum Discussion
How to get the Percent Difference from previous data
- Anonymous2 years ago
Hi, rkxiii
You can try the following methods.
Measure:
Diff = Var _Prevdate=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),[Date]<SELECTEDVALUE('Table'[Date]))) Var _PrevYield=CALCULATE([Yield],FILTER(ALL('Table'),[Date]=_Prevdate)) RETURN IF(_PrevYield=BLANK(),BLANK(),[Yield]-_PrevYield)Is this the result you expected?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi rkxiii, Hope you are doing good!
Please try the below DAX to create a new calculated column as per your requirement:
Difference =
VAR PreviousPercent =
CALCULATE(
MAX(TableName[Percent]),
FILTER(
TableName,
TableName[IndexColumn] = EARLIER(TableName[IndexColumn]) - 1
)
)
RETURN
IF(
ISBLANK(PreviousPercent),
0,
TableName[Percent] - PreviousPercent
)
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Hi, Thank you for your response.
I used the PowerBi Visual "Table" for the table used in the image, is the solution still applicable?
Is it also possible just to add "New Measure" for the percentage? Thank you.