Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I have a requirement where the background color of the numbers needs to be changed based on the slicer selection.
- If the Region is selected as East, the Postal code is less than 50 and the sales are less than 10,000 then "RED" else "GREEN"
- If the Region is selected as West, the postal code is less than 60, and the sales are less than 20,000 then "RED" else "GREEN"
Here is the link to the sample dataset: https://www.kaggle.com/datasets/rohitsahoo/sales-forecasting
Solved! Go to Solution.
@ghoshabhijeet Apologies for the delay in response. I got the reply for the percentage data type in this post: https://community.powerbi.com/t5/Desktop/Conditionally-formatting-values-in-a-table-based-on-slicer/...
@Marico Here is my solution. Please try this:
Create the following three measures:
Color Code EAST =
VAR PostalCode = COUNTX(train,train[Postal Code])
VAR RSales = SUMX(train,train[Sales])
RETURN
SWITCH(
TRUE(),
AND(PostalCode < 50, RSales < 10000), "Red",
"Green")
Color Code WEST =
VAR PostalCode = COUNTX(train,train[Postal Code])
VAR RSales = SUMX(train,train[Sales])
RETURN
SWITCH(
TRUE(),
AND(PostalCode < 60, RSales < 20000), "Red",
"Green")
Switch Color Codes =
IF (
SELECTEDVALUE ( RegionTable[Region] ) = "East",
[Color Code EAST],
[Color Code West]
)
After creating the above three measures,
1. Goto Format Visuals
2. Goto Cell elements
3. Select Sales under Apply Settings to
4. Select Background Color
5. Under Format Style, Select Field value
6. Under What field should we base this on?, Select Switch Color Codes measure
7. Click OK
Here is the result:
** If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution, so that it comes in top of the search and help others. Thank you ! Good Luck 👍 |
Thanks for your detailed answer.
However, in the actual data the fields are of percentage data type. Could you please suggest how to modify the above measures in that case?
@MaricoSure, could you please share some sample data with what you are referring to as percentage data type.
** If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution, so that it comes in top of the search and help others. Thank you ! Good Luck 👍 |
@Marico Could you please share some sample data with what you are referring to as percentage data type.
** If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution, so that it comes in top of the search and help others. Thank you ! Good Luck 👍 |
@ghoshabhijeet Apologies for the delay in response. I got the reply for the percentage data type in this post: https://community.powerbi.com/t5/Desktop/Conditionally-formatting-values-in-a-table-based-on-slicer/...
@Marico Ok.
** If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution, so that it comes in top of the search and help others. Thank you ! Good Luck 👍 |
User | Count |
---|---|
96 | |
89 | |
71 | |
63 | |
58 |
User | Count |
---|---|
149 | |
113 | |
95 | |
80 | |
72 |