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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

how to calculate a distinctcount taking into account all the filters (slicer & the filter section) ?

Hello,

You can find the pbix file related to my issue below here : https://we.tl/t-PusCT9Zjmc 

I have two card visuals, one to show the distinct elements "machines" in the whole table, I do like this and it works fine :

 

NbDistinctTotal = calculate(DISTINCTCOUNT('Table'[machine]), all('Table')) + 0

 

I have a slicer on my page.

I have another measure where I want to display the distinct elements "machines", but only of the ones left after my "filters" are applied. It's like this :

 

NbDistinct = DISTINCTCOUNT('Table'[machine]) + 0

 

Pb : It takes into account the filter of my slicer but not the filter selected on my filter section (to the right of the power bi reports).

In the image below, when I select machine 1 in the filter on the right, I want my card NbDistinct to display the same value as shown in the filter beside each possible value (2, 1, 1). Instead of this, it remains written 3 (which is the number of distinct machine with the SiteName selected in the slicer).

jmclej2_0-1681733948313.png

I cannot upload my pbix sample file (do you know how to do it ?) so here is the code of queries :

Table :

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUpUitWJVjICspLALGO4mAmcZQpkpYJZqDrS4DrSlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Colonne 1" = _t, #"Colonne 2" = _t]),
    #"Type modifié" = Table.TransformColumnTypes(Source,{{"Colonne 1", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Type modifié",{{"Colonne 1", "machine"}, {"Colonne 2", "Location"}})
in
    #"Renamed Columns"

 

Slicer :

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WysvPNVTSUUpUitUBc4yAnCQYxxjISVaKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Colonne 1" = _t, #"Colonne 2" = _t]),
    #"Type modifié" = Table.TransformColumnTypes(Source,{{"Colonne 1", type text}, {"Colonne 2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Type modifié",{{"Colonne 1", "SiteManager"}, {"Colonne 2", "SiteName"}})
in
    #"Renamed Columns"

 

And here is the relationship between the two : 

jmclej2_1-1681730095614.png

 

2 REPLIES 2
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Anonymous
Not applicable

Thanks for your input.

Here is the pbix file relating my issue : https://we.tl/t-PusCT9Zjmc

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors