cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

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

Hi, @kamsingh11 

 

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

Hi, @kamsingh11 

 

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

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

Memorable Member
Memorable Member

Hi @kamsingh11 

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
https://www.linkedin.com/in/amine-jerbi-2b3a8928/

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

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
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors