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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
nelalx
Regular Visitor

Filter a measure using value from another slicer

Hello ,

I am trying to filter the value of a card with the selectedvalue from a slicer. 

nelalx_0-1669244597472.png

I have a slicer using the country field whose value I obtain by using selectedvalue. I am then trying to create a measure which calculates the distinctcount of deviceid from devicedetails using the below DAX.

Measure = CALCULATE(DISTINCTCOUNT(devicedetails[DeviceId]),FILTER(devicedetails,devicedetails[DCountry]=[selectedvalue]))

But i am always getting back blank in the visual. Can someone please help me fix this? Also by default when no selection is made in slicer, selecyedvalue measure also does not have a value. How can i handle this scenario ?

 

Kindly help me. 

1 ACCEPTED SOLUTION

What do you want to show if nothing is selected in the slicer?

 

You could use an if statement and hasonevalue to determine if the slicer has a single selection. If it doesn't, then return whatever default value you want.

https://learn.microsoft.com/en-us/dax/hasonevalue-function-dax

 

You could also try using chiclet slicer (download the visual) and force a selection in the slicer so it is never blank.

View solution in original post

4 REPLIES 4
nelalx
Regular Visitor

Many thanks for the suggestion..

djurecicK2
Super User
Super User

Hi @nelalx ,

 Not sure you need to do this. What happens if you just create a measure with Distinctcount of device id and put that in your visual. Does the measure value change when county slicer changes?

Actually i am facing a more complex issue and I tried this as a solution. The below is my relationships. 

nelalx_0-1669246809094.png

I am trying to find the unique deviceids when a slicer of country from the country field is applied. The devicedetails table also has a country field named DCountry, but i am not able to filter the value. Hence i tried to capture the value from slicer which uses the country field from country table and apply it on devicedetails table. 

 

I am able to get it to work now , it looks like the country field in devicedetails table had some spaces. a trim helped it. But can you pleasse tell me how to handle the default case. I mean if no value is selected in slicer, i am having the card shown as blank.

What do you want to show if nothing is selected in the slicer?

 

You could use an if statement and hasonevalue to determine if the slicer has a single selection. If it doesn't, then return whatever default value you want.

https://learn.microsoft.com/en-us/dax/hasonevalue-function-dax

 

You could also try using chiclet slicer (download the visual) and force a selection in the slicer so it is never blank.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.