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
sebastienke
Helper III
Helper III

How to change conditionnal formating setting with a slicer ?

Hi, 

 

There are many topics about conditionnal formating but I didn't found what I was looking for. Maybe you can help me. 

 

I have a matrice representing % (issued from a measure) through time.

I have a slicer which allow the user to display the % category he want to check.

 

sebastienke_0-1613997399733.png

 

Each category of this slicer has a target max identified.

sebastienke_2-1613997777333.png

 

I would like to have in my matrice green background when % is under the target and red when it is over.

 

Thank you for your help.

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @sebastienke ,

 

In this case you need to use a measure similar to this one:

 

Formatting =
SWITCH (
    TRUE (),
    SUM ( 'Table'[Value] ) >= MAX ( Target[Target_Max] )
        && SELECTEDVALUE ( 'Table'[Cat] ) IN VALUES ( Target[Cat] ), "Green",
    SUM ( 'Table'[Value] ) <= MIN ( Target[Target_Max] )
        && SELECTEDVALUE ( 'Table'[Cat] ) IN VALUES ( Target[Cat] ), "Red"
)

 

In this case I have used everything on the same table:

MFelix_0-1614000001838.png

But it will work properly if you use a slicer. 

 

Looking at the information you are providing I believe ytou need to use the same measure that you use for changing the calculation based on your target but add the MAX / MIN target value part.

 

If you are not abble to convert the measure to what you need can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @sebastienke ,

 

In this case you need to use a measure similar to this one:

 

Formatting =
SWITCH (
    TRUE (),
    SUM ( 'Table'[Value] ) >= MAX ( Target[Target_Max] )
        && SELECTEDVALUE ( 'Table'[Cat] ) IN VALUES ( Target[Cat] ), "Green",
    SUM ( 'Table'[Value] ) <= MIN ( Target[Target_Max] )
        && SELECTEDVALUE ( 'Table'[Cat] ) IN VALUES ( Target[Cat] ), "Red"
)

 

In this case I have used everything on the same table:

MFelix_0-1614000001838.png

But it will work properly if you use a slicer. 

 

Looking at the information you are providing I believe ytou need to use the same measure that you use for changing the calculation based on your target but add the MAX / MIN target value part.

 

If you are not abble to convert the measure to what you need can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Actually the problem was not the measure Formatting (even if SWITCH is actually a better solution than mine), but how to use it in the conditionnal formatting parameters. Thanks to your example file, i was able to do what i wanted to !

 

Thanks @MFelix    

negi007
Community Champion
Community Champion

@sebastienke What i understand from above that you wish to have conditional formating basis the slicer selection. You want to these 4 slicers value to change the conditional formating. However, looking at your Target Min and Target Max it has comma seperated values. Please tell me how will you have conditional formatting for such values. If possible please share your powerbi sample file with more details.




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



Proud to be a Super User!


Follow me on linkedin

coma is my decimal separator. So 0,05 means 5%.

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.