Hopefully I can explain this sufficiently ... we have a table with a set of scores for various tasks and for each person carrying out these tasks, we need to calculate an overall score with a max score from each category. Given the below
Person Code Score
1 a 10
1 a 12
1 a 4
1 b 3
1 c 2
1 c 5
2 a 8
2 b 16
2 b 6
2 c 12
2 c 3
3 b 3
3 b 5
3 c 2
3 c 7
4 a 2
4 a 3
4 b 4
4 b 2
4 c 5
4 c 1
What we have is for each person, they have three tasks. We want to sum up their score for each task to a max of 20 points giving a priority to task a then b then c. Once we've determined the categorisation we then apply a multiplier depending on the task
(multiply by 4 for task a, 3 for task b and 2 for task c). This will give us the following results
Person a (*4) b (*3) c (*2) total
1 20 0 0 80
2 8 12 0 68
3 0 8 9 42
4 5 6 6 50
Once we've got each person's total, we want to get the average.
So in SSAS, we want for each person, sum up their a, b and c scores, determine how many points in each task actually applies (i.e. stop when we hit 20 points in total) and apply the multiplier. I have attempted to use
First get score for each task
a Score:=MAXX(SUMMARIZE( 'Person';'Person'[id]); CALCULATE(sum([Score]); 'Score'[Task] = "a"))
b Score:=MAXX(SUMMARIZE( 'Person';'Person'[id]); CALCULATE(sum([Score]); 'Score'[Task] = "b"))
c Score:=MAXX(SUMMARIZE( 'Person';'Person'[id]); CALCULATE(sum([Score]); 'Score'[Task] = "c"))
then limit to 20 across the board
a20:=IF([a Score]>20; 20; [a Score])
b20:=IF([b Score]+[a20]>20; 20-[a20]; [b Score])
c20:=IF([c Score]+[b20]+[a20]>20; 20-[b20]-[a20]; [c Score])
and then calculate the average
ave:=AVERAGEX(SUMMARIZE( 'person' ;'person'[Id])
;CALCULATE([a20]*4 + [b20]*3 + [c20]*2; ))
I know there are a few faults
- I have no idea what to use instead of "MAXX" in the first set
- I'm certain I'm causing a double loop by doing the summarize in both the first set and the average calculation but no other "average" function likes the calculation as its entry (something about needs to be a single column)
The output would appear to be selecting the max score for the group (80 in my above example) rather than calculating the average (60) which as my best guess is because the MAXX is determining the 80 score and
passing that back to the average for every person.
If I don't put the summarize section for the score calculations, it appears to be adding up the relevant task for ALL people rather than only that task for the current subject person.
Any suggestions highly appreciated!