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

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

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.