Forum Discussion

ngiam's avatar
ngiam
Helper I
4 years ago

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

  • ValtteriN's avatar
    ValtteriN
    Community Champion

    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!
    • ngiam's avatar
      ngiam
      Helper I

      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?

      • ValtteriN's avatar
        ValtteriN
        Community Champion

        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.