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
Anonymous
Not applicable

Distinct Counts on Filtered Table

I'm having some trouble getting the intended distinct count numbers on a filtered table. From the results I'm seeing it appears as though the filtered table isn't actually filtered, so I'm not sure if that's the problem or if I'm using the wrong DAX.

 

The link to OneDrive containing the PBIX file is here.

 

GOAL

 

I have the following two DAX measures:

 

TEST UNIQUE COUNT = DISTINCTCOUNT('Test Table'[Super Bowl Ad Link])
&
TEST TOTAL UNIQUE COUNT = CALCULATE('Measures Table'[TEST UNIQUE COUNT]ALL('Test Table'))
 

I have a slicer on a table upstream of 'Test Table' called 'Category Table'[Category], and when 'Category Table'[Category] = 'Animals', I'm expecting to see the following splits by 'Test Table'[Brand]:

 

BrandTEST UNIQUE COUNTTEST TOTAL UNIQUE COUNT
Bud Light410
Budweiser59
Coca-Cola26
Doritos49
E-Trade02
Hyundai37
Kia37
NFL06
Pepsi16
Toyota17

 

PROBLEM

 

I'm actually seeing the following table:

 

BrandTEST UNIQUE COUNTTEST TOTAL UNIQUE COUNT
Bud Light1069
Budweiser969
Coca-Cola669
Doritos969
E-Trade269
Hyundai769
Kia769
NFL669
Pepsi669
Toyota769

 

I think there may be a problem with the data model, in the screenshot below, it seems like the the 'Category Table' isn't filtering the 'Test Table' for some reason. Also I can't connect 'Category Table' to the 'Superbowl Data' as that will mess up all my visuals.

 

tomgprice411_0-1642762174609.png

 

The problem seems fairly trivial, so it may have been posted about before. I couldn't find any other posts regarding this when I searched, so apologies if it has already been covered.

 

Any help would be appreciated.

1 ACCEPTED SOLUTION
Richard_100
Resolver I
Resolver I

Hello

 

I was able to show your required data using this measure:

 

TEST TOTAL UNIQUE COUNT 2 =
CALCULATE(
DISTINCTCOUNT('Test Table'[Super Bowl Ad Link]),
ALL('Category Table'[Category])
)
 
Putting the ALL against the 'Category Table' rather than the 'Test Table' removes the "= Animals" filter over the table, making the DISTINCTCOUNT work.  I also used the DISTINCTCOUNT formula directly within the CALCULATE instead of referencing the [TEST UNIQUE COUNT] measure to avoid the hidden nested CALCULATE stuff
 
Richard_100_1-1642765481002.png

 

Hope that helps

 

Regards

Richard


 

View solution in original post

5 REPLIES 5
Whitewater100
Solution Sage
Solution Sage

Hi:

I think this solution maybe be similiar. Is this correct for you? You want to not use Table Descriptions when you have a measure in the formula..Thanks

TEST UNIQUE COUNT =
DISTINCTCOUNT('Test Table'[Super Bowl Ad Link])
 
New Measure II = CALCULATE(
[TEST UNIQUE COUNT],
REMOVEFILTERS('Category Table'[Category])
)
 
New Measure = CALCULATE(
DISTINCTCOUNT('Test Table'[Category])
)
Richard_100
Resolver I
Resolver I

Hello

 

I was able to show your required data using this measure:

 

TEST TOTAL UNIQUE COUNT 2 =
CALCULATE(
DISTINCTCOUNT('Test Table'[Super Bowl Ad Link]),
ALL('Category Table'[Category])
)
 
Putting the ALL against the 'Category Table' rather than the 'Test Table' removes the "= Animals" filter over the table, making the DISTINCTCOUNT work.  I also used the DISTINCTCOUNT formula directly within the CALCULATE instead of referencing the [TEST UNIQUE COUNT] measure to avoid the hidden nested CALCULATE stuff
 
Richard_100_1-1642765481002.png

 

Hope that helps

 

Regards

Richard


 

Anonymous
Not applicable

Hi Richard,

 

Thanks for your answer, your formula for TEST TOTAL UNIQUE COUNT 2 has worked. I'm just wondering how you got the TEST UNIQUE COUNT function to work? Screenshot below. 

 

TEST UNIQUE COUNT = DISTINCTCOUNT('Test Table'[Super Bowl Ad Link])

 

For some reason the TEST UNIQUE COUNT is ignoring the filter on 'Category Table'[Category].

 

tomgprice411_0-1643100320123.png

 

Hello

 

I left your original DAX for the TEST UNIQUE COUNT untouched, this is a visual with your two original measures plus my new total. 

 

I use the 'Category Table'[Category] field for the filter, not the 'Test Table'[Category] field.  Your original TEST UNIQUE COUNT is showing the 4, 5, 2, 4, etc numbers as below in my view

 

Orig TEST UNIQUE COUNT =
DISTINCTCOUNT('Test Table'[Super Bowl Ad Link])

 

Richard_100_0-1643110262245.png

 

I can see you've said that it's ignoring the 'Category Table'[Category] filter but if you could just double check and then maybe share your workbook again?  (By the way, sharing the pbix file was very helpful)

 

Hope that helps anyway

 

Regards

Richard

Anonymous
Not applicable

Ah sorry yes I wasn't using the filter correctly. Thanks a lot for your help!

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.