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

Be 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

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.