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
anwarbi
Helper II
Helper II

Calculating Average of Distinct count of values using slicer variable

Hi,

 

Newbie here, I am trying to calculate average by category, based on the ALLSelected values in slicer.

 

In the below measure, I am considering Variable as all the selected company names in the slicer, then for those companies, I am calculating distinctcount of email_ID and then averagex of each companies.

 

However, the output i am getting is 1, which is incorrect.

 

I am using the below measure:

 
Peer group distinct count =
VAR SelectedPeers = ALLSELECTED('Peer Group'[Company])
return
    AVERAGEX(
    FILTER('raw_data','raw_data'[Company] IN SelectedPeers),
    CALCULATE(DISTINCTCOUNT('raw_data'[email_id]))
)
 
Please note that Peer Group'[Company] in the above measure is a value from table created using the values from  raw_data'[Company].  
Below is the sample table and the expected output:
 
Company nameDistinct count of email id
Company A35
Company B40
Company C25
Company D17
Company E37
Company F24

 

So for example, If i select Company A, Company B and Company C in the slicer I should get an average output of 33 (which is an average of 35,40 and 25).  

 

Appreciate if you are able to help me solve this. 

 

Best,

Anwar

2 REPLIES 2
TomMartens
Super User
Super User

Hey @anwarbi ,

 

please create a pbix file containing sample data that still reflects your data model (tables, relationships, calculated columns, and measures). Upload the pbix to onedrive, Google Drive, or Dropbox and share the link. If you are using Excel to create the sample data instead of the manual input method, share the xlsx as well.

Do not forget to create a table that contains the expected result based on given filters.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks Tom for your response. I will try to upload the data, if it helps. Thank you!

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.