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
golandriel
Frequent Visitor

How to use a Slicer for counting distinct values?

Hi all,

 

I want to use a slicer to filter my data set on how many entries I have for one ID. In my example I want to know every tree that has exactly one bush in a perimeter of 100m. In my table every tree has a distance to the next bush and the bushes are numbered sorted by distance (see the table below). I want to set my slicer that the result should be 1 (only the tree with the ID 3). If I want to know how many trees have exactly 2 bushes in a perimeter of 100m, the result should also be 1 (only the tree with the ID 2)

 

Right now when I set my slicer (Number of Bushes) on 1 it returns all three trees because every tree has at least 1 Bush in its perimeter. How can I fix this?

 

Thank you!

 

Tree IDBush IDDistance in mNumber of Bushes

1

300301
1301502
1302703
2400151
2401202
3500101
4 REPLIES 4
Anonymous
Not applicable

Hi @golandriel 

 

Thanks for the reply from @iceparrot , please allow me to provide another insight:

First of all, I create a new table:

 

Table 2 = VALUES('Table'[Number of Bushes])

 

vzhengdxumsft_0-1712286921510.png

Then add a measure:

 

MEASURE =
VAR _Slicer =
    MAX ( 'Table 2'[Number of Bushes] )
VAR _currenttreeID =
    MAX ( 'Table'[Tree ID] )
VAR _countofBush =
    CALCULATE (
        MAX ( 'Table'[Number of Bushes] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Tree ID] = _currenttreeID )
    )
RETURN
    IF ( _countofBush = _Slicer, _countofBush )

 

The report can be like:

vzhengdxumsft_1-1712286996244.pngvzhengdxumsft_2-1712287005928.png

The result is as follow:

vzhengdxumsft_4-1712287039975.pngvzhengdxumsft_5-1712287046801.pngvzhengdxumsft_6-1712287053015.png

Best Regards

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

Thank you for your help @Anonymous!

 

It's not quite the result I am looking for. If I change the distance to 60m Tree ID 1 has also two bushes in a perimeter of 60m and should therefore appear in the list. But it won't appear in the list because the (max) measure of that tree ID is 3.

golandriel_0-1712316888217.png

 

Do you have an idea how I can fix that?

 

Best regards

Frederik

 

 

 

iceparrot
Advocate II
Advocate II

Hey @golandriel , 

according to your description you want to filter by the amount of Bushes in a specified distance, right?

If your answer is yes, you could just use a second date slicer and use the field Distance in m as an additional filter. 
I used the demo data provided by you and this is how it looks like with two date slicers:

iceparrot_1-1712225366461.png

 

 

 

Hi @iceparrot,

thanks for your reply. Not quite! I already have a slicer for the distance. If you set your slicer to 100m and your slicer for the number of bushes to 1 it would still return all 3 tree IDs. In my case I need a slicer that only returns the ID for trees with exactly 1 bush in 100m (Tree ID 3).

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.

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.