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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
anwarbi
Helper III
Helper III

Calculating Average of distinct count by category

Hi,

 

I am looking to calculate average of distinct count of respondents by Peers.

 

Here is the dummy data, I have two tables in power bi.

Table 1 is a master table with all the data fields and table 2 only have 'Peers' name which I have created the relation with 'partner' field in table 1.

 

I am looking to create a measure that calculates a distinct count of respondent ID (from table 1) for the peers (in table 2, please note that the peers should be static and not affected by any filters in the report.

And then calculate the average of distinct count of respondents for each peer.

 

Output:

The calculated measure should give the following output e.g.  Peer (A) has 2 unique responses, Peer (B) has 3 unique responses. So the average will be 2.5 for both peers.   

I hope this gives enough data points. Thanks. 

 

Table 1

partner

Respondent ID

A

A1212

B

B1212

A

A1212

D

C1212

E

B1212

B

A1212

A

B1212

H

D1212

B

B1212

B

D1212

  

Table 2

Peers

A

B

Thanks.

1 ACCEPTED SOLUTION

Hi, @anwarbi 

 

You can use peers field and the measure in visual, then filter out other partners in filter pane by using advanced filtering:value is not blank.

Like this:

meassure =
AVERAGEX (
    VALUES ( Table2[Peers] ),
    CALCULATE ( DISTINCTCOUNT ( Table1[Respondent ID] ) )
)

vjaneygmsft_0-1636618654147.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If problem still persists, pls let me know.

 

Best Regards,
Community Support Team _ Janey

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@anwarbi , Create measure like

 

averageX(Values(Table2[Peers]), calculate(distinctcount(Table1[Respondent ID])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks Amit for your help. While the measure is correct, it is not giving me the desired result.

 

Currently, this measure calculates the output for all the Partners in table 1, however, I only want the output based on the Peers (i.e. just for A&B) in table 2.  

 

Please note that i do not want to have a drop-down filter to select the desired peers. the calculation should be restrcited to Peers in table 2.

 

 

Hi, @anwarbi 

 

You can use peers field and the measure in visual, then filter out other partners in filter pane by using advanced filtering:value is not blank.

Like this:

meassure =
AVERAGEX (
    VALUES ( Table2[Peers] ),
    CALCULATE ( DISTINCTCOUNT ( Table1[Respondent ID] ) )
)

vjaneygmsft_0-1636618654147.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If problem still persists, pls let me know.

 

Best Regards,
Community Support Team _ Janey

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.