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
lukaszbrdon
Frequent Visitor

Distinct Count per day and than sum of those per month

Hi All,

 

How to create the measure that will firstly calculate distinct count per day and than will sum those result to month level.

as per example:

dateid
01/01/2021a
01/01/2021b
02/01/2021a
02/01/2021b
02/01/2021c
03/01/2021a
15/01/2021a
15/01/2021b


Needed measure:

DateMeasure Distinct Count per dayper month
01/01/202128
02/01/202138
03/01/202118
04/01/202128


Thank you in advance.

1 ACCEPTED SOLUTION
truptis
Community Champion
Community Champion

@lukaszbrdon 
Try this:
m1 = var distinct_count_id = countrows(summarize(tablename,[date],[id]))
return 
sum(distinct_count_id)

this will return total sum of distinct values.

if you need it on a monthly level, use the date hierarchy thing and select month and year. this way, only month wise sum of distinct ids would show up.

Hope this helps you.
Regards,
TruptiS

View solution in original post

4 REPLIES 4
lukaszbrdon
Frequent Visitor

 

Thank you, but it is not what i am looking for. It's a part of more complicated measure, so I need achieve that within the maesure.


the sum() can be used only for column, there is no possibility to create such Measure.

 

truptis
Community Champion
Community Champion

@lukaszbrdon 
Try this:
m1 = var distinct_count_id = countrows(summarize(tablename,[date],[id]))
return 
sum(distinct_count_id)

this will return total sum of distinct values.

if you need it on a monthly level, use the date hierarchy thing and select month and year. this way, only month wise sum of distinct ids would show up.

Hope this helps you.
Regards,
TruptiS

lukaszbrdon
Frequent Visitor

Thank you, but it is not what i am looking for. It's a part of more complicated measure, so I need achieve that within the maesure.

truptis
Community Champion
Community Champion

Hi @lukaszbrdon ,
You don't need a measure to have count per day. 
Take a table visual, Drag in Date and ID field. On the ID field, right click and see Count option. It will give you the count.
& for the total, keep the total on on the format pane. 

truptis_0-1647003655129.png

Also, for distinct count, you can select Distinct of Count option after the right click.


Hope this helps.

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.