Forum Discussion
Background Color based on Slicer Selection
Hello all,
I have a requirement to change background color of a shape based on the filtered values from any of the slicers included on the report. The measure I have so far works but it changes the background color of all the shapes instead of the one that is filtered. Also, in the case where a slicer values filters down to two or more statuses, it doesn't highlight anything. See examplese below. I've also included a link to a sample pbix file.
https://drive.google.com/file/d/1GQoOzNfLmfjDFtX7Evn9J3Z9FFuzlYrC/view?usp=drive_link
DAX measure for background colore:
Example 1, when filtered to Company 1 no background color is changed because there is more than one status. The requirement is to only highlight the filtered statuses so there would only be 2 shapes with a blue background.
Example 2, when filtered to Company all backgrounds change. The requirement is to only highlight the filtered status(es) so there would only be 1 shape with a blue background.
- Anonymous2 years ago
Hi ajrodr198203 ,
Thanks for the reply from danextian , please allow me to provide another insight:
You can try formula like below:
11 = VAR sel_practise = SELECTEDVALUE ( 'Table'[Requesting Practice] ) VAR choose = SELECTEDVALUE ( 'Table'[Requesting Practice] ) & " " & SELECTEDVALUE ( 'Table'[Order Status] ) VAR target_ = MAX ( data[Requesting Practice] ) & " " & MAX ( data[Order Status] ) VAR count_ = COUNTROWS ( FILTER ( data, data[Requesting Practice] = sel_practise ) ) RETURN IF ( count_ > 0, "Blue", IF ( choose = target_, "Blue", "Gray" ) )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- danextianSuper User
Hi ajrodr198203
Look into using ISFILTERED which returns true when the specified table or column is being filtered directly so if a filter is applied to Column A but not Column B, it returns true only for Column A.
- AnonymousNot applicable
Hi ajrodr198203 ,
Thanks for the reply from danextian , please allow me to provide another insight:
You can try formula like below:
11 = VAR sel_practise = SELECTEDVALUE ( 'Table'[Requesting Practice] ) VAR choose = SELECTEDVALUE ( 'Table'[Requesting Practice] ) & " " & SELECTEDVALUE ( 'Table'[Order Status] ) VAR target_ = MAX ( data[Requesting Practice] ) & " " & MAX ( data[Order Status] ) VAR count_ = COUNTROWS ( FILTER ( data, data[Requesting Practice] = sel_practise ) ) RETURN IF ( count_ > 0, "Blue", IF ( choose = target_, "Blue", "Gray" ) )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.