Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I want to be able to populate the Category column depending on the values selected by the slicer.
Slicer 1
1, 2 or 3
Slicer 2
4, 5 or 6
| Value | Category |
| 1 | A |
| 2 | A |
| 3 | A |
| 4 | B |
| 5 | B |
| 6 | C |
| 7 | C |
Category =
var category_value_A = selectedvalue([Slicer 1])
var category_value_B = selectedvalue(Slicer 2])
return
switch(TRUE, [Value] <= category_value_A, "A",
[Value] <= category_value_B, "B",
"C")
I have tried the code above and it only works for the first condition and then exits the switch.
Hi @theaddies ,
May I ask if your [Slicer1] and [Slicer2] are the following two columns?
Here are the steps you can follow:
1. Create measure.
Measure =
var category_value_A = MAXX(ALLSELECTED(Slicer_Table),[Slicer1])
var category_value_B = MAXX(ALLSELECTED(Slicer_Table),[Slicer2])
return
SWITCH(
TRUE(),
MAX('Table'[Value])<=category_value_A,"A",
MAX('Table'[Value])>category_value_A&&MAX('Table'[Value])<=category_value_B,"B",
"C")
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Each slicer is a generated series. The Maxx function does not work as it selects the final value in the series.
Try the below.
Category =
var category_value_A = selectedvalue([Slicer 1])
var category_value_B = selectedvalue(Slicer 2])
return
switch(TRUE, [Value] <= category_value_A, "A",
[Value] >= category_value_B, "B",
"C")
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |