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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AlexW24
New Contributor

Distinct with multiselect slicer

How can I update the following to allow multiple selected values in a slicer?

 

Distinct Apps = 
CALCULATE(
    DISTINCTCOUNT(AppUsage[AppName]), 
    FILTER(
        AppUsage, 
        AppUsage[UserName] <> SELECTEDVALUE(DeveloperTable[UserName]
        )
    )
)

 

I have a report that shows app useage data.  The visuals show the apps and the number of users that access each app.  There is a slicer that has the names of developers and when I select a developer, the visuals updates and removes any app userage data with that developer's name.  There is also a card that uses the measure I posted above that shows the distict number of apps.  The measure works when selecting one developer at a time, but how do I get it to work with multiple selected developers?

1 ACCEPTED SOLUTION
tayloramy
Contributor

Hi ,  

Youโ€™re running into a classic SELECTEDVALUE limitation: it only returns a single value. With multiple developers selected, SELECTEDVALUE goes blank, so your filter logic no longer excludes the chosen names. 

Use the IN operator against the selected list, and guard for the โ€œno selectionโ€ case so you donโ€™t exclude everyone by accident:

Distinct Apps =
VAR HasDevFilter =
ISFILTERED(DeveloperTable[UserName])
VAR SelectedDevs =
VALUES(DeveloperTable[UserName]) -- all developers currently selected in the slicer
RETURN
IF (
NOT HasDevFilter, -- nothing selected: show all apps (no exclusions)
DISTINCTCOUNT ( AppUsage[AppName] ),
CALCULATE (
DISTINCTCOUNT ( AppUsage[AppName] ),
REMOVEFILTERS ( DeveloperTable[UserName] ), -- ignore slicerโ€™s direct filter first
NOT ( AppUsage[UserName] IN SelectedDevs ) -- then exclude selected developers
)
)

 

If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution. 

@AlexW24

View solution in original post

3 REPLIES 3
tayloramy
Contributor

Hi ,  

Youโ€™re running into a classic SELECTEDVALUE limitation: it only returns a single value. With multiple developers selected, SELECTEDVALUE goes blank, so your filter logic no longer excludes the chosen names. 

Use the IN operator against the selected list, and guard for the โ€œno selectionโ€ case so you donโ€™t exclude everyone by accident:

Distinct Apps =
VAR HasDevFilter =
ISFILTERED(DeveloperTable[UserName])
VAR SelectedDevs =
VALUES(DeveloperTable[UserName]) -- all developers currently selected in the slicer
RETURN
IF (
NOT HasDevFilter, -- nothing selected: show all apps (no exclusions)
DISTINCTCOUNT ( AppUsage[AppName] ),
CALCULATE (
DISTINCTCOUNT ( AppUsage[AppName] ),
REMOVEFILTERS ( DeveloperTable[UserName] ), -- ignore slicerโ€™s direct filter first
NOT ( AppUsage[UserName] IN SelectedDevs ) -- then exclude selected developers
)
)

 

If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution. 

@AlexW24

@tayloramy Thank you for the solution!  Prior to coming here for help, I did try to make it work with the "IN" function but I was nowhere close to what you provided.  This seems like an overly complicated formula just to allow multiple selected items.  I hope Microsoft makes this easier in the future.  

 

Thanks again for the solution!

v-saisrao-msft
Honored Contributor II

Hi @AlexW24,

Thank you @tayloramy, for your insights.

I've reproduced the issue and received the following output. I've also attached the pbix file for your reference.

vsaisraomsft_0-1758616692732.png

Hope this helps

 

Thank you.

Helpful resources

Announcements
Top Solution Authors
Users online (8,586)