Forum Discussion
Help with year on year calculation
- Anonymous1 year ago
Hi Fusilier2
Thanks for the reply from SachinNandanwar .
Fusilier2 , the following testing is for your reference.
My sample:
Create two measures as follow.
LastYear = VAR _LastYear = MAX([Year]) - 1 VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _LastYear)) RETURN _sumDivide = VAR _MaxYear = MAX([Year]) VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _MaxYear)) RETURN DIVIDE(_sum, [LastYear])Output:
If the data structure I use is different from what you use, please provide some sample data and the expected results based on the sample data so that we can better help you. How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Fusilier2
Thanks for the reply from SachinNandanwar .
Fusilier2 , the following testing is for your reference.
My sample:
Create two measures as follow.
LastYear =
VAR _LastYear = MAX([Year]) - 1
VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _LastYear))
RETURN
_sum
Divide =
VAR _MaxYear = MAX([Year])
VAR _sum = CALCULATE(SUM('Table'[Value]), FILTER('Table', [Year] = _MaxYear))
RETURN
DIVIDE(_sum, [LastYear])
Output:
If the data structure I use is different from what you use, please provide some sample data and the expected results based on the sample data so that we can better help you. How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.