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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Mattm1989
Regular Visitor

Issue with variance calculations

Hi

 

Please could someone help me understand what I am doing wrong?

 

I am using variables to calculate the sum of the same column but using different selections based on a different column via slicers. I then want to find the difference between those 2 totals. See below:

Mattm1989_0-1727347214351.png

The issue is the difference comes back as blank when 2 different options are selected from the slicer.

Currently here is my DAX:

 

Var01 =
VAR Actual_Bud_01 = SELECTEDVALUE(Master[Actual / Budget1])
VAR Total_Act_Bud_01 = CALCULATE(SUM(Master[Amt USD - PTD1]), Master[Actual / Budget1] = Actual_Bud_01)
RETURN Total_Act_Bud_01
Var02 =
VAR Actual_Bud_02 = SELECTEDVALUE(Master[Actual / Budget1])
VAR Total_Act_Bud_02 = CALCULATE(SUM(Master[Amt USD - PTD1]), Master[Actual / Budget1] = Actual_Bud_02)
RETURN Total_Act_Bud_02
 
Var_diff2 = [Var01] - [Var02]
 
I have edited interactions as such (opposite selection for the other slicer):

Mattm1989_1-1727347389572.png

Also if the same selection is selected across both filters, the difference will return 0:

Mattm1989_2-1727347484069.png

Thank you!



1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @Mattm1989 

Unfortunately the slicers count as an AND filter on the card.

Meaning it tries to filter your Master table to only rows that fufill BOTH criteria.

 

You can either:

Use one slicer and have the two measures return only one of the items in the list. If the user can only ever choose one using Min on one and max on the other would work. 

Var01 =
VAR Actual_Bud_01 = Max(Master[Actual / Budget1])
VAR Total_Act_Bud_01 = CALCULATE(SUM(Master[Amt USD - PTD1]), Master[Actual / Budget1] = Actual_Bud_01)
RETURN Total_Act_Bud_01
 
Or you have a second copy of the Master[Actual/budget] column in a seperate and completely unlinked table for the second calculation.

 

Var01 =
VAR Actual_Bud_01 = SelectedValue(MasterCopy[Actual / Budget1])
VAR Total_Act_Bud_01 = CALCULATE(SUM(Master[Amt USD - PTD1]), Master[Actual / Budget1] = Actual_Bud_01)
RETURN Total_Act_Bud_01
 
 
Let me know if you get stuck 🙂

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

2 REPLIES 2
Mattm1989
Regular Visitor

Makes complete sense now! I've gone for a completely separate table on second calc and getting the result I require! thank you!

SamWiseOwl
Super User
Super User

Hi @Mattm1989 

Unfortunately the slicers count as an AND filter on the card.

Meaning it tries to filter your Master table to only rows that fufill BOTH criteria.

 

You can either:

Use one slicer and have the two measures return only one of the items in the list. If the user can only ever choose one using Min on one and max on the other would work. 

Var01 =
VAR Actual_Bud_01 = Max(Master[Actual / Budget1])
VAR Total_Act_Bud_01 = CALCULATE(SUM(Master[Amt USD - PTD1]), Master[Actual / Budget1] = Actual_Bud_01)
RETURN Total_Act_Bud_01
 
Or you have a second copy of the Master[Actual/budget] column in a seperate and completely unlinked table for the second calculation.

 

Var01 =
VAR Actual_Bud_01 = SelectedValue(MasterCopy[Actual / Budget1])
VAR Total_Act_Bud_01 = CALCULATE(SUM(Master[Amt USD - PTD1]), Master[Actual / Budget1] = Actual_Bud_01)
RETURN Total_Act_Bud_01
 
 
Let me know if you get stuck 🙂

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.