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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
BrisbanePom
New Member

Return Selected Item(s) from a slicer in a measure

I am looking to filter reports based on a list of Staff Members chosen from a slicer.  I want to show which values are selected in a card.

If one value is selected, return its value (Staff Name).  If none explicitly selected, return "All Selected".  If more than one, show "N Selected" where N is the number of boxes checked.

 

The following code works in the first 2 scenarios, but when multiple items are selected it returns "All Selected":

Slicer Selected Measure =
VAR selected = SELECTEDVALUE(Staff_Details[Staff Member])
RETURN IF (
ISBLANK(selected),
"No Staff Member Selected",
IF (
DISTINCTCOUNT(Staff_Details[Staff Member]) = 1,
selected,
CONCATENATE(DISTINCTCOUNT(Staff_Details[Staff Member]), " Staff Members Selected")
)
)

How to fix this so that it returns the values as required?

 

 

1 ACCEPTED SOLUTION
AntrikshSharma
Super User
Super User

@BrisbanePom 

Measure = 
VAR SelectedMember = 
    COUNTROWS ( VALUES ( Staff_Details[Staff Member] ) )
VAR All_Members = 
    COUNTROWS ( ALL ( Staff_Details[Staff Member] ) )
VAR Result = 
    SWITCH ( 
        TRUE(),
        All_Members = SelectedMember, "All Selected",
        SelectedMember = 0, "No Member Selected",
        SelectedMember = 1, SELECTEDVALUE ( Staff_Details[Staff Member] ),
        SelectedMember > 1, SelectedMember & " Staff members Selected"
    )
RETURN Result

View solution in original post

3 REPLIES 3
BrisbanePom
New Member

Perfect - works a treat!

AntrikshSharma
Super User
Super User

@BrisbanePom 

Measure = 
VAR SelectedMember = 
    COUNTROWS ( VALUES ( Staff_Details[Staff Member] ) )
VAR All_Members = 
    COUNTROWS ( ALL ( Staff_Details[Staff Member] ) )
VAR Result = 
    SWITCH ( 
        TRUE(),
        All_Members = SelectedMember, "All Selected",
        SelectedMember = 0, "No Member Selected",
        SelectedMember = 1, SELECTEDVALUE ( Staff_Details[Staff Member] ),
        SelectedMember > 1, SelectedMember & " Staff members Selected"
    )
RETURN Result

Hi Anriksh

I've now extended this logic to multiple slicers interacting on the same table (Staff Details).  Unfortunately this breaks the intended logic of the solution - if for example Staff Member John is explicitly selected, the corresponding Measure for Staff Team goes from All Selected to "1 Team Selected" because the rows in the filtered table are filtered from the whole.

What I am looking for is a measure that shows only the Slicers where a value has been explicitly chosen - even if the team is implicitly selected by the application of the Staff Member filter.  Is there a way to do this that returns the results of the Checked values in the slicer itself ,as opposed to a measure based on the filtered table rows? 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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