Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 21 | |
| 12 | |
| 9 | |
| 5 | |
| 5 |