Forum Discussion
Average based on distinct values in another column
- 10 years ago
This should work (tested locally):
Measure = AVERAGEX(SUMMARIZE(Table1, Table1[Employee], Table1[Age]), Table1[Age])
- Anonymous10 years ago
Hi bullius,
You can also create the measure using the formula.Measure = AVERAGEX(VALUES(Table[Employee]), CALCULATE(AVERAGE(Table[Age])))
Thanks,
Lydia Zhang
First of all, that was a really good clarification post, thank you for making it easy to understand your situation.
I think the measure that you had (DISTINCTCOUNT) was close, what you wanted was just some way to divide by total transactions. There's probably a few ways to do this, I'm a bit rusty so the first one that came to my mind was using CALCULATE. Here's the measure I used:
Measure 2 = DISTINCTCOUNT('Transaction'[Transaction ID])/CALCULATE(DISTINCTCOUNT('Transaction'[Transaction ID]), ALL('ItemID'[Category]))
Note that the first bit is the same as your measure, and then you divide it by the count of transactions across all categories. It gives the results you said were the expected (you might need to delete and remake your measure so it reformats). I hope that helps!
Amazing! This is exactly what i was looking for!
Thanks for your help, especially considering this is already a solved topic and you won't get the credit ;)
Have a lovely weekend ahead and holidays if you're celebrating!
- jahida8 years agoImpactful Individual
Haha no problem, glad to help. Like I said, you made it easy. Happy Holidays to you too!