Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Using a value for multiple different filters (selecting just one filter) - dynamically switch

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. 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

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)))

7.png8.png

 

3. add Measure2 in the Visual level filter

select "show values when item is" 1

9.png10.png

 

 

Best Regards

Maggie

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

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)))

7.png8.png

 

3. add Measure2 in the Visual level filter

select "show values when item is" 1

9.png10.png

 

 

Best Regards

Maggie

Anonymous
Not applicable

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!

dedelman_clng
Community Champion
Community Champion

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.