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! Learn more

Reply
Enigma
Helper III
Helper III

Count unique values in one column after applying filter on another one

Hi,

I have this measure that first filters out all rows from a date column that are older than a given date; and then counts the rows in 'Document Key' column.

 

Under1Year = COUNTX(FILTER('Inventory',[Content Current Date].[Date] >= CONVERT("03/01/2019",DATETIME)),'Inventory'[Document Key])

 

This was working fine.

Now, there's an additional requirement to count only unique values from that column. I modified the formula as below but none of them worked.

This one gave the same result as the above original formula(which I know is incorrect as there are duplicate values present in the 'Document Key' column after the date filter is applied)

 

Under1Year = COUNTX(FILTER('Inventory',[Content Current Date].[Date] >= CONVERT("03/01/2019",DATETIME)),DISTINCTCOUNT('Inventory'[Document Key]))

 

Then I tried this one and, as expected, it threw a runtime error as DSTINCTCOUNT only accepts a column as an argument.

 

Under1Year = DISTINCTCOUNT(COUNTX(FILTER('Inventory',[Content Current Date].[Date] >= CONVERT("03/01/2019",DATETIME)),'Inventory'[Document Key]))

 

 
Any suggestions on how to get this to work?

 

- Regards

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Something like this maybe:

Mdis = CALCULATE(DISTINCTCOUNT(Inventory'[Document Key]), Inventory[[Content Current Date]] >= DATE(2020, 03, 01))

View solution in original post

2 REPLIES 2
HotChilli
Super User
Super User

Something like this maybe:

Mdis = CALCULATE(DISTINCTCOUNT(Inventory'[Document Key]), Inventory[[Content Current Date]] >= DATE(2020, 03, 01))

Thanks @HotChilli 

Worked perfectly 🙂

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.