March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have created a calculation item for This Year and Prior Year and wanted to calculate Variance for it.
But the varaince calculation item is not working
A calculation group is only called once per measure, so you cannot nest them like this. You would either need to have the variance in a separate calculation group or replicate the time intelligence logic in the TY & LY calculation items.
Thank You for responding, I tried both ways did'nt work
Try
Variance =
VAR ThisYear =
CALCULATE ( SELECTEDMEASURE (), DATESYTD ( 'Date'[Date] ) )
VAR LastYear =
CALCULATE (
SELECTEDMEASURE (),
DATEADD ( DATESYTD ( 'Date'[Date] ), -1, YEAR )
)
VAR Result = ThisYear - LastYear
RETURN
Result
Hi @han_rj
Could you please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
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.
@v-zhengdxu-msft , Thank You for responding
This is the sample data
Calculation Items used
Expected
I want variance for the current year only
Hi @han_rj
Please try this:
First of all, Create a measure:
Measure = SUM('Table'[Sales])
Then add a calculation group:
Last_Year = CALCULATE(SELECTEDMEASURE(),'Table'[Last_Year_Ind] = "Y")
This_Year = CALCULATE(SELECTEDMEASURE(),'Table'[This_Year_Ind] = "Y")
YOY =
CALCULATE ( SELECTEDMEASURE (), 'Table'[This_Year_Ind] = "Y" )
- CALCULATE ( SELECTEDMEASURE (), 'Table'[Last_Year_Ind] = "Y" )
Finally, create a Matrix and 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.
Thank You @v-zhengdxu-msft for responding the format I am looking for is like this
CY, TY label and the Year.
If we exclude the Year in the column we get the correct results but when we add Year to the column the variance is off like this
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
16 | |
15 | |
7 | |
7 |
User | Count |
---|---|
37 | |
31 | |
16 | |
16 | |
12 |