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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.