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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Mann
Resolver III
Resolver III

Returning desired result from different filter selection

Hi Guys,

 

I have a simple dataset as shown:

100A
200A
250B
270C
340D
400D
430B
500C

 

My requirement is to show a measure on card for sum of sales for Country "C" and "D" only. The issue I am facing is with filter selection and getting desired results. I want following:

 

1) If only C is selected in filter then sum of sales of C should come like:

1.PNG

2) If only A or B is selected then it should show "NA" for which I created this formula:

Total Sales = 
VAR TotalSales= SUM(Test[Sales])
VAR MySelection = SELECTEDVALUE(Test[Country])
Return
SWITCH(TRUE(),
       MySelection = "A", "NA",
       MySelection = "B", "NA",
       MySelection = "C", TotalSales,
       MySelection = "D", TotalSales,
       TotalSales)

This is how its coming if only "A" is selected:

2.PNG

This is what I want now, If multiple values are selected then following results should come:

a) If A and B is selected, Card should show "NA"

b) If A and C is selected (Same when B and C is selected), Card should show total sales of C only.

c) If A and D is selected (Same when B and D is selected), Card should show total sales of D only. 

d) If C and D is selected, Card should show total sales of C and D.

 

That is I want to ignore the contributing sales of "A" and "B" when they are selected in multiple selections.

 

Thanks.

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Mann 

 

Try following MEASURE

 

Measure =
VAR check =
    INTERSECT ( VALUES ( Test[Country] ), { "C", "D" } )
RETURN
    IF ( NOT ( ISEMPTY ( check ) ), CALCULATE ( SUM ( Test[Sales] ), check ), "NA" )

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@Mann 

 

Try following MEASURE

 

Measure =
VAR check =
    INTERSECT ( VALUES ( Test[Country] ), { "C", "D" } )
RETURN
    IF ( NOT ( ISEMPTY ( check ) ), CALCULATE ( SUM ( Test[Sales] ), check ), "NA" )

Regards
Zubair

Please try my custom visuals

Hi @Zubair_Muhammad 

 

Thanks Alot! This measure works as expected!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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