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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BIQuest321
Frequent Visitor

Subtract values based on two slicer selections

Hey All,

 

Been noodling this all day and coming up short so far. Essentially I will have two slicers that are supposed to offer dynamic comparisons of fact table data. These are basic calculations such as distinct counts. But I want to be able to select "Option A" from "Slicer A" and subtract "Option B" from "Slicer B". In the screenshot you see an example of two slicers, their distinct count below and the final piece I need is populating the math for the visual comparing the two. 

 

Very simple example of my fact table

IDNameDescription
1AetnaA
2AetnaB
3AetnaC
4BCBS ArizonaA
5BCBS ArizonaB
6BCBS Arizona

C

 

 

pbi_questions.png

1 ACCEPTED SOLUTION
bolfri
Solution Sage
Solution Sage

bolfri_0-1679610392367.png

 

 

Create 2 tables:

Option A = GROUPBY(SampleData,SampleData[Name])
Option B = GROUPBY(SampleData,SampleData[Name])
 
Create 3 measures:
Option A Value = CALCULATE([Average ID],SampleData[Name] in VALUES('Option A'[Name]))
Option B Value = CALCULATE([Average ID],SampleData[Name] in VALUES('Option B'[Name]))
B minus A = [Option B Value] - [Option A Value]
 
You can add also 2 more bonus measures to prevent from selecting same name in A & B at the same time:
Not in A = IF(SELECTEDVALUE('Option B'[Name]) in VALUES('Option A'[Name]),0,1)
Not in B = IF(SELECTEDVALUE('Option A'[Name]) in VALUES('Option B'[Name]),0,1)
Put those measures on filters with condition = 1.
 
bolfri_1-1679610566261.png

 

In this case you can't select Aetna, because it's on Option A, but if on option A will be Bolfri > Bolfri will dissapear from Option B, and Aetna will be avaliable to select.

 

PBIX file: https://we.tl/t-GVWssWxBpX

 





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
bolfri
Solution Sage
Solution Sage

bolfri_0-1679610392367.png

 

 

Create 2 tables:

Option A = GROUPBY(SampleData,SampleData[Name])
Option B = GROUPBY(SampleData,SampleData[Name])
 
Create 3 measures:
Option A Value = CALCULATE([Average ID],SampleData[Name] in VALUES('Option A'[Name]))
Option B Value = CALCULATE([Average ID],SampleData[Name] in VALUES('Option B'[Name]))
B minus A = [Option B Value] - [Option A Value]
 
You can add also 2 more bonus measures to prevent from selecting same name in A & B at the same time:
Not in A = IF(SELECTEDVALUE('Option B'[Name]) in VALUES('Option A'[Name]),0,1)
Not in B = IF(SELECTEDVALUE('Option A'[Name]) in VALUES('Option B'[Name]),0,1)
Put those measures on filters with condition = 1.
 
bolfri_1-1679610566261.png

 

In this case you can't select Aetna, because it's on Option A, but if on option A will be Bolfri > Bolfri will dissapear from Option B, and Aetna will be avaliable to select.

 

PBIX file: https://we.tl/t-GVWssWxBpX

 





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

Proud to be a Super User!




Hey bolfri,

 

New day new problem. With the original premise basically still in tact here, how could I display the actual descriptions that are different or in common between A and B?

For example:
Option A has: A, B, C, D, E
Option B has: B, E, X, Y, Z

Result would return what they do or don't have in common:

Result (A,B): X, Y, Z
Result (B,A): A, C, D

Is this possible without duplicating the fact table?? Obviously considering a much more complex scaled up example doubling the data is extremely performance prohibative. 

 

Edited - Okay I misunderstood your solution and my apologies on that. After reviewing your file this does exactly what I'm looking for without duplicating the fact table. Nicely done that's really slick!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors