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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ngiam
Helper I
Helper I

Help needed with DistinctCount & Average

Dear All,

 

I want to create a card that shows the;

  1. Count number of Employee who has less than Average Sales of $100 for Client from Category Main (Refer to table below) 
  2. Count number of Employee who has less than Average Sales of $100 for Client from Category Secondary (Refer to table below) 
    I've created a slicer that allows me to selecte between Main or Secondary

Sales Table

Employee NameClientSales 
RayC1100
RayC2150
RayC3125
BobC1

120

Bob C2100
BobC4100
CatC5150
CatC2160
CatC4175

 

Client Table

ClientCategory
C1Main
C2Main
C3Main
C4Secondary
C5Secondary
C6Secondary

 

Am currently trying this out ; 

Filter = CALCULATE(
DISTINCTCOUNT('Sales Table'[Name]),
AVERAGE('Sales Table'[Sales] <100, 
FILTER('Client Table', 'Client Table'[Category]="Secondary" || 'SkillLibrary'[Category]="Main"))
)
But doesn't seems to work for me.
 
Appreciate some hints to help me with this!
6 REPLIES 6
ValtteriN
Super User
Super User

Hi,

Your formula was quite close. This counts the number of employees with whose average sales are less than 100 (customerCategory = "Main"):

AverageTest = calculate(DISTINCTCOUNT(Sales[Employee Name]),

filter(Sales,AVERAGEX(FILTER(Sales,RELATED(ClientCategory[Category])="Main"),Sales[Sales ])<100))


For secondary count replace "Main" with "Secondary".

I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you very much for your help!

 

I seem to have this as an error

 

"The column 'ClientCategory[Category]' either doesn't exist or doesn't have a relationship to any table available in the current context."

 

Anything that I should be looking out for?

Hi,

Check the table name, I used a slightly different one than the one in your example. (Client Table -> ClientCategory). Additionally, I had a relationship between the Sales and client table.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you ValtteriN,

 

Am using the right table. Do many-many relationship has any impact to this?

 

Thanks!

Yeah, M:N will break RELATED. Here is a formula that works with that relation:

AverageTest =

calculate(DISTINCTCOUNT(Sales[Employee Name]),

filter(Sales,AVERAGEX(
SUMMARIZE(filter(Sales,Sales[Client] in SUMMARIZE(FILTER('ClientCategory',ClientCategory[Category]="Main"),ClientCategory[Client])),Sales[Employee Name],Sales[Client],"AV",AVERAGE(Sales[Sales ]))
 
,Sales[Sales ])<100))




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you! This seems to work!

 

That said, it seems to work well for non-decimal numbers and doesn't seems to be workable for number with decimal. Is there a way to enable average of numbers with decimal?

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors