Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi everyone,
I have included a SWITCH function in a slider to alternate a visualization between a measure "A", a measure "B" and the sum of both if nothing is selected in the slider. The functions is as follows:
From the description of your problem, it seems the issue arises from the multi-value nature of the `VALUES` function when there's no selection in the slicer. This is especially true for visuals that expect single values.
1. When a single item is selected from the slicer:
- `ISCROSSFILTERED` returns TRUE and we enter the `SWITCH` function.
- `VALUES` will return a table with a single value, hence the comparisons you're making with `VALUES(Balances[Concepto])` are valid.
2. When no item is selected in the slicer:
- `ISCROSSFILTERED` returns FALSE.
- The formula goes to the else-part, which is `[BF_CA]+[BF_TD]`, and there shouldn’t be a problem here as it’s just a sum of two measures.
3. When multiple items are selected:
- This is probably where the problem arises. `VALUES` returns a table of multiple values, which isn’t valid for direct comparisons like `VALUES(Balances[Concepto]) = "Curr. Acc."`. If the visual is expecting a single value, it'll throw an error.
BF_Slicer =
VAR SelectedValueCount = COUNTROWS(VALUES(Balances[Concepto]))
RETURN
IF(
SelectedValueCount = 0, [BF_CA] + [BF_TD],
IF(
SelectedValueCount = 1,
SWITCH(TRUE(),
VALUES(Balances[Concepto]) = "Curr. Acc.", [BF_CA],
VALUES(Balances[Concepto]) = "Term dep.", [BF_TD],
BLANK()
),
BLANK() -- This line handles multiple selections, you can modify this to return a specific value or just blank
)
)
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
111 | |
104 | |
103 | |
87 | |
61 |
User | Count |
---|---|
162 | |
132 | |
131 | |
95 | |
86 |