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
Hi everyone!
I have a satisfaction survey comparing some years (2017, 2016, 2015...)
Then I have a column with a lot of different departments like: "A"; "B"; "C"; "D"...
The problem is that in older years, I have to use the same result from "EF" to compare "A" and/or "B" from newer years, for example.
It means that when I select to see "A" area, I need to see the following results:
"A" - 2017
"A" - 2016
"EF" - 2015
When I select "B", I need to see:
"B" - 2017
"B" - 2016
"EF" - 2015
I don't want to select "A" or "B" and "EF" in filters! Just one, or "A" or "B"!
I tried using SWITCH function
tested the formula: IF(SELECTEDVALUE(Survey[department])="A";"A";"B") and it works when I just see it in my viewer chart, but when i put it inside my switch function it do NOT works! (tried even formulas that won't work in my logical like CONTAINS, ISFILTERED, ISCROSSFILTERED, HASONEVALUE, etc. None of then work inside Switch, only outside)
What am I doing wrong? Does Switch function works with variable statements?
Is there another way to solve this?
The formula I tried is:
Department2=
VAR selectedarea = IF(SELECTEDVALUE(Survey[department])="A";"A";"B")
Return
SWITCH(Survey[department],
"A"; "A";
"B"; "B";
"C"; "C";
[...]
"EF"; selectedarea;
"ERROR")
I thought that if I selected "A" in this new measure, the SELECTEDVALUE should not work because Survey[department] would have "A" and "EF" selected, but I could not figured out a way to validade the IF Statement.
Sorry for my bad english.
Thanks in advance.
Solved! Go to Solution.
Hi @Anonymous
1.Create a new table with only one column from your "survey" table
Table = FILTER(VALUES(Sheet7[department]),[department]<>"EF")
Then add this column in the new table to a default slicer .
2. create two measures
Measure = SELECTEDVALUE('Table'[department])
Measure 2 = IF([Measure]=MAX([department]),1,IF([Measure]="A"||[Measure]="B",IF(MAX([department])="EF",1,0)))
3. add Measure2 in the Visual level filter
select "show values when item is" 1
Best Regards
Maggie
Hi @Anonymous
1.Create a new table with only one column from your "survey" table
Table = FILTER(VALUES(Sheet7[department]),[department]<>"EF")
Then add this column in the new table to a default slicer .
2. create two measures
Measure = SELECTEDVALUE('Table'[department])
Measure 2 = IF([Measure]=MAX([department]),1,IF([Measure]="A"||[Measure]="B",IF(MAX([department])="EF",1,0)))
3. add Measure2 in the Visual level filter
select "show values when item is" 1
Best Regards
Maggie
Oh! thank you very much @v-juanli-msft it really works!
@dedelman_clng Sorry for the late reply, was trying to understand the method hehe. Now i'm with new knowledges!
Check out this article for use of SWITCH ( TRUE () ... )
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |