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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors