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
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
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.