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
Anonymous
Not applicable

Help with measure to see right color when "All" is selected in Slicer

Hi,

 

When I select a particular country from slicer, I get the correct result as shown below in the pie chart. I have a green and a red option of pie chart similarly and it all works fine. Green is for positive values and Red is for negative values

kamsingh11_1-1610552172438.png

But when I select "All" from the slicer, I only get blank image as shown below:

kamsingh11_2-1610552376482.png

 

I am using the following measures to show green and red. Eaxmple as follows:

Green = IF(([Delta] > [Error Margin]), 1, 0)
 

I am struggling with writing the measure for that. How can I show a different color instead when "All" is selected, say orange color? 

 

Thanks for the help!

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

d1.png

 

You may create measures as below.

Green = 
IF(
    HASONEVALUE('Table'[Country]),
    IF(
        SUM('Table'[Delta])>SUM('Table'[Error Margin]),
        1,0 
    ),
    0
)
Red = 
IF(
    HASONEVALUE('Table'[Country]),
    IF(
        SUM('Table'[Delta])<=SUM('Table'[Error Margin]),
        1,0
    ),
    0
)
Orange = 
IF(
    HASONEVALUE('Table'[Country]),
    0,
    1
)

 

Result:

d2.pngd3.pngd4.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

d1.png

 

You may create measures as below.

Green = 
IF(
    HASONEVALUE('Table'[Country]),
    IF(
        SUM('Table'[Delta])>SUM('Table'[Error Margin]),
        1,0 
    ),
    0
)
Red = 
IF(
    HASONEVALUE('Table'[Country]),
    IF(
        SUM('Table'[Delta])<=SUM('Table'[Error Margin]),
        1,0
    ),
    0
)
Orange = 
IF(
    HASONEVALUE('Table'[Country]),
    0,
    1
)

 

Result:

d2.pngd3.pngd4.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you so much! I never used HASONEVALUE before. This will be handy for sure!

aj1973
Community Champion
Community Champion

Hi @Anonymous 

The Card color depends on the name of the country right? if so then you would want to use SWITCH formula.

What are those measures [Delta] , [Error Margin] ?

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

color card depends on the values represented by Green and Red measures for the selected country. There are several countries. When we select a particular country, color shown by Green and Red measures are fine. But when "All" in Country slicer is selected, the color card becomes blank and I would like it to be some color by creating a new measure that represents "All" in the slicer. 

Thanks for your help!

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.