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
Anonymous
Not applicable

Distinct Count ignoring one column plus calculate average

Hello, all!

 

I have the following table 

malone_henrique_0-1713968479352.png

And im trying to get a simple DISTINCT COUNT[ID] but its not working because the column Type has two different values (B and E).

If i use a mesure, it works BUT im trying to use a Column because after i get the distinct count, ill need get the average.

Like the example below:

malone_henrique_1-1713968695737.png

In short, i need to get the average of distinct count[id].

 

Ive tried create a column with 

CALCULATE(DISTINCTCOUNT(Consult[id]) / DISTINCTCOUNT(Consult[date].[Month]), ALLSELECTED(Consult[date].[Day]))
 
But its not working because its counting the same ID twice when the ID has the B and E type.
 
If there is a way to get the column average that i need using a measure, ill be glad to learn how.
 
Thanks! 
1 ACCEPTED SOLUTION
barritown
Super User
Super User

Hi @Anonymous,

Try this piece of code:

barritown_0-1713989272528.png

In plain text:

Avg_Distinct_ID = 
VAR _tbl = SUMMARIZE ( 'Table', [Year], [Month], "dValue", DISTINCTCOUNT ( 'Table'[ID] ) ) 
RETURN AVERAGEX ( _tbl, [dValue] )

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

View solution in original post

1 REPLY 1
barritown
Super User
Super User

Hi @Anonymous,

Try this piece of code:

barritown_0-1713989272528.png

In plain text:

Avg_Distinct_ID = 
VAR _tbl = SUMMARIZE ( 'Table', [Year], [Month], "dValue", DISTINCTCOUNT ( 'Table'[ID] ) ) 
RETURN AVERAGEX ( _tbl, [dValue] )

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

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.