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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to get multiple Slicer selections to variable?

Hello there, 

I have a slicer with 5 options: Bing, Facebook, Google, NewTraffic and SteelHouse.

I am trying to get selected value from the slicer into a variable. I am able to get it correctly if there is only one of these selected. However, if i select Bing and Google, i cant get it to work. 

In order to do the test i created a measure and presented it in a "Card" visual. The measure looks like this:

SlicerTest =
VAR SELECTION = SELECTEDVALUE(SlicerOptions[DataSource])
return SELECTION

As I mentioned, it returns if i select one value but if i select multiple, it returns blank. 

The reason why i need to do multiple selection is because I am using switch function later that will drill my data based on multiple selection


SlicerSelectionRevPlan =
VAR SELECTION = SELECTEDVALUE(PlanDataSources[DataSource])
Return
SWITCH(TRUE(),
SELECTION = "Google", [GoogleRevenuePlan],
SELECTION = "Google" && "Bing", [GoogleRevenuePlan]+[BingRevenuePlan],
SELECTION = "Bing",[BingRevenuePlan],
SELECTION = "SteelHouse",[SteelHouseRevenuePlan],
SELECTION = "Facebook", [FacebookRevenuePlan],
CALCULATE(SUM(PaidPlans[RevenuePlan]))
)

This switch function works fine with single selection. So what i was trying to do is implement selection where if Google and Bing are selected, than the revenue plan for google and bing will be added. 

Any idea how to solve this?


1 ACCEPTED SOLUTION
Duia
Resolver II
Resolver II

Hi  @Anonymous ,

I created some data:

Duia_0-1660140630608.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _selelct=SELECTCOLUMNS('PlanDataSources',"select",[DataSource])
return
CALCULATE(
    SUM('PlanDataSources'[RevenuePlan]),FILTER(ALL(PlanDataSources),
    'PlanDataSources'[DataSource] in _selelct))

2. Result:

Duia_1-1660140630610.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Duia
Resolver II
Resolver II

Hi  @Anonymous ,

I created some data:

Duia_0-1660140630608.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _selelct=SELECTCOLUMNS('PlanDataSources',"select",[DataSource])
return
CALCULATE(
    SUM('PlanDataSources'[RevenuePlan]),FILTER(ALL(PlanDataSources),
    'PlanDataSources'[DataSource] in _selelct))

2. Result:

Duia_1-1660140630610.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@Anonymous , For the first one try like

SlicerTest =
VAR SELECTION = concatenatex(SlicerOptions, SlicerOptions[DataSource], ", ")
return SELECTION

 

For second

 

SlicerSelectionRevPlan =
VAR SELECTION = values(PlanDataSources[DataSource])
Return
SWITCH(TRUE(),
"Google" in SELECTION , [GoogleRevenuePlan],
"Google" && "Bing" in SELECTION , [GoogleRevenuePlan]+[BingRevenuePlan],
"Bing" in SELECTION ,[BingRevenuePlan],
"SteelHouse" in SELECTION ,[SteelHouseRevenuePlan],
"Facebook" on SELECTION  , [FacebookRevenuePlan],
CALCULATE(SUM(PaidPlans[RevenuePlan]))
)
 
or
 
SlicerSelectionRevPlan =
VAR SELECTION = values(PlanDataSources[DataSource])
Return
Sumx( PlanDataSources,
if("Google" in SELECTION , [GoogleRevenuePlan],blank()) +
if("Google" && "Bing" in SELECTION , [GoogleRevenuePlan]+[BingRevenuePlan],blank()) +
if("Bing" in SELECTION ,[BingRevenuePlan],blank()) +
if("SteelHouse" in SELECTION ,[SteelHouseRevenuePlan],blank()) +
if("Facebook" on SELECTION , [FacebookRevenuePlan],blank()) )
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Actually that doesnt work. 
The solution for :
SlicerTest =
VAR SELECTION = concatenatex(SlicerOptions, SlicerOptions[DataSource], ", ")
return SELECTION

Is fine. 

However, 
When i try to pass this selection down to my switch function or your second solution it didnt work. 
It does not recognise SELECTION within 

"Google" in SELECTION , [GoogleRevenuePlan],

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors