The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
99 | |
93 | |
81 | |
63 | |
56 |
User | Count |
---|---|
248 | |
123 | |
111 | |
78 | |
74 |