Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Matrix - variance measure showing incorrectly

Hi All, 

 

I've created two measures:

1. To calculate total budget:  Calculate(Sum([Amount]), Cost Type = "Budget')

2. To calculate YTD actuals and forecast for future months: 

 

YTD Actuals =

Var LastDate = CALCULATE(MAX([Data[MonthDate]), Data[Type] = "Actuals", REMOVEFILTERS())
RETURN 
IF(SELECTEDVALUE(DimDate[Date]) <= LastDate, 
CALCULATE(SUM(Data[Amount]), DATESYTD(DimDate[Date], "30/06"), Type="Actuals"))

 

Forecast for Future Months: 

Var YTD Forecast = TOTALYTD(SUM(Data[Amount]), Data[MonthDate], Data[Type] = "Forecast", "30/06")
RETURN 
CALCULATE([YTD Forecast], FILTER(Data, Data[Month Num] > SELECTEDVALUE(DimDate[FiscalMonthNum])))


Actuals + Forecast: 
YTD Actuals + Forecast for Future Months

 

I've pulled the Total Budget and Actuals+Forecast measures into a matrix visual that looks like this (see table below). It drills down from outsource and BAU costs into the cost types. I've pulled in my budget and variance measures into this visual and it works great. H

 

owever, when i do Budget - Forecast/Actuals to get the variance, it does a weird calculation and it gives me the incorrect variance. 

 

Would anyone know how to fix this? Thank you so much in adv!

 

TypeCost TypeAmount
Outsource CostsBudgetMeasure 1 
 ForecastMeasure 2
 VarianceMeasure 1 - Measure 2
BAU CostsBudget 
 Forecast 
 Variance 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

The use of measures is based on context and the calculation on overall totals are different from the ones on the single line, so the calculation sometimes can get weird because of the context transiction.

 

Check this article.

 

In this case and having you being a calculated measure based on an if statement believe that the best option is to have a SUMX type of calculation something similar to:

 

Variance = SUMX(VALUES(Table[Type]), [Budget] - [Forecast/Actuals])

 

Be aware that without detaisl about your model this may not work.

 

If you cannot achieve expected result can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous ,

 

The use of measures is based on context and the calculation on overall totals are different from the ones on the single line, so the calculation sometimes can get weird because of the context transiction.

 

Check this article.

 

In this case and having you being a calculated measure based on an if statement believe that the best option is to have a SUMX type of calculation something similar to:

 

Variance = SUMX(VALUES(Table[Type]), [Budget] - [Forecast/Actuals])

 

Be aware that without detaisl about your model this may not work.

 

If you cannot achieve expected result can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Thanks @MFelix !

 

I jsut added in SUMX function and "ALL" filter and it seemed to work now! 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors