Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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.
@Anonymous , 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 @Anonymous 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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
10 | |
10 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |