Forum Discussion
Help needed with DistinctCount & Average
Hi,
Your formula was quite close. This counts the number of employees with whose average sales are less than 100 (customerCategory = "Main"):
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!
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?
- ValtteriN4 years agoCommunity 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.- ngiam4 years agoHelper I
Thank you ValtteriN,
Am using the right table. Do many-many relationship has any impact to this?
Thanks!
- ValtteriN4 years agoCommunity Champion
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))