Forum Discussion
Anonymous
8 years agoNot applicable
SUM value by category
I am trying to take the following data and calculate the values for each person. person sales Average Jerry 30 10 Jerry 30 10 Jerry 30 10 Tom 25 12.5 Tom 25 12.5 ...
- Anonymous8 years ago
I don't agree that this is the right way to do this, using measures you can calculate this information display it without needing to store the value on every single line in your data set (which is what a calculated column will do). Never the less, this is the calculated column code to do what you are asking:
This will produce your calculated column for salesTotal Sales = var thisPerson = [person] RETURN CALCULATE( SUM('YourTable'[sales]) ALL('YourTable'), 'YourTable'[person] = thisPerson )
This calculates the averageTotal Average = var thisPerson = [person] RETURN DIVIDE( [Total Sales], CALCULATE( COUNTROWS('YourTable') ALL('YourTable'), 'YourTable'[person] = thisPerson ) )
v-danhe-msft
Microsoft Employee
8 years agoHi Anonymous,
Could you please post me your desired result?
Regards,
Daniel He