Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I'm using the Switch function to define conditional formatting for icons in a matrix as follows:
This works well, however in my matrix table i'm also using a slicer to switch between which measure is displayed (e.g. i toggle between the sales mesaure displayed in the matrix, and the sales % mesaure).
I want to apply seperate thresholds for conditional formatting icons for each measure.
I've tried incorporating SELECTEDVALUE to the measure, but i can;'t figure it out. Can you advise how to combine selectedvalue and switch to achieve this (or an alternative?)
e.g.
Sales Icon =
Switch(SELECTEDVALUE
TRUE(),
[SALES] > 1000, "TrafficHighLight",
[SALES] < -100, "TrafficLowLight",
[SALES%] > 5%, "TrafficHighLight",
[SALES%] < -5% "TrafficLowLight",
"TrafficMediumLight"
)
Solved! Go to Solution.
Try this solution. The logic in the first variable is explained here:
https://www.sqlbi.com/blog/marco/2022/06/11/using-selectedvalue-with-fields-parameters-in-power-bi/
1. Create measure:
Sales Icon =
VAR vSelectedMeasure =
SELECTCOLUMNS (
SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
"Parameter", Parameter[Parameter]
)
VAR vResult =
SWITCH (
vSelectedMeasure,
"Sales",
SWITCH (
TRUE,
[Sales] > 1000, "TrafficHighLight",
[Sales] < -100, "TrafficLowLight"
),
"Sales %",
SWITCH (
TRUE,
[Sales %] > .05, "TrafficHighLight",
[Sales %] < -.05, "TrafficLowLight"
)
)
RETURN
vResult
2. In the format pane of the visual (matrix in this example), go to Cell elements, enable Icons, click the fx button, and select the Sales Icon measure:
Do this for each measure in your field parameter (you have to individually select each value in your field parameter slicer and apply these steps). You can also set conditional formatting via the user interface, but a measure enables you to define the logic in one place (easier maintenance).
Here's a list of icon names for conditional formatting:
https://radacad.com/power-bi-icon-names-for-conditional-formatting-using-dax
Proud to be a Super User!
Try this solution. The logic in the first variable is explained here:
https://www.sqlbi.com/blog/marco/2022/06/11/using-selectedvalue-with-fields-parameters-in-power-bi/
1. Create measure:
Sales Icon =
VAR vSelectedMeasure =
SELECTCOLUMNS (
SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
"Parameter", Parameter[Parameter]
)
VAR vResult =
SWITCH (
vSelectedMeasure,
"Sales",
SWITCH (
TRUE,
[Sales] > 1000, "TrafficHighLight",
[Sales] < -100, "TrafficLowLight"
),
"Sales %",
SWITCH (
TRUE,
[Sales %] > .05, "TrafficHighLight",
[Sales %] < -.05, "TrafficLowLight"
)
)
RETURN
vResult
2. In the format pane of the visual (matrix in this example), go to Cell elements, enable Icons, click the fx button, and select the Sales Icon measure:
Do this for each measure in your field parameter (you have to individually select each value in your field parameter slicer and apply these steps). You can also set conditional formatting via the user interface, but a measure enables you to define the logic in one place (easier maintenance).
Here's a list of icon names for conditional formatting:
https://radacad.com/power-bi-icon-names-for-conditional-formatting-using-dax
Proud to be a Super User!
User | Count |
---|---|
96 | |
87 | |
78 | |
72 | |
69 |
User | Count |
---|---|
113 | |
105 | |
84 | |
65 | |
64 |