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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.