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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors