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
ochec
New Member

Counting unique rows per day

Hi all, 

 

I have a table (Account) with 5 columns (simplified for simplicity sake). 

There's also and table with calendar dates ([Dates]).

 

I want to know the total count of unique codes per day (date) where
AML = 1 and the date is greater than/equal to start date and less than end date.

 

I'm hoping to create a measure or even calculated column (and then create measure off that)

 

I have tried a few things but none seem to do the trick.

 

Count AML:=
COUNTROWS (
FILTER(
Account,
Account[Start Date] <= RELATED('Dates'[Date])
&& Account[End Date] >= RELATED('Dates'[Date])
&& (Account[AML]= 1)
))

 

Appreciate any help.

 

[Account] table below. Only column id is unique

id,code,Start Date,End Date, AML
1,123,2018-12-12,2018-12-13,1
2,123,2018-06-25,2018-12-12,1
4,456,2018-06-25,2018-12-12,1
5,789,2018-06-25,2018-11-01,0

 

e.g

Eg date: 2018-06-24
Total count for code 123 is 0
Total count for code 456 is 0
Total count for code 768 is 0

 

Eg date: 2018-06-25
Total count for code 123 is 1
Total count for code 456 is 1
Total count for code 789 is 0

 

Eg date: 2018-06-26
Total count for code 123 is 1
Total count for code 456 is 1
Total count for code 768 is 0

 

Eg date: 2018-10-31
Total count for code 123 is 1
Total count for code 456 is 1
Total count for code 768 is 0

 

Eg date: 2018-12-12
Total count for code 123 is 1
Total count for code 456 is 0
Tota count for code 789 is 0

 

Eg date: 2018-12-13
Total count for code 123 is 0
Total count for code 456 is 0
Total count for code 768 is 0

1 REPLY 1
Anonymous
Not applicable

Do this in Power Query. Create a table with columns Date,Code,TotalWithAML. Date column will hold all the dates from your Dates table. Code will hold all the possible codes. TotalCountWithAML will be easy to calculate in Power Query. Once you have such a table, you join Date to Dates[Date] and Code to Account[Code] or some table that will hold the unique codes... Then you can slice and dice to your heart's content.

Best
Darek

Helpful resources

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.