I have a table in MS Access which lists KPI (performance) scores for each person
USERID KPI SCORE MODIFIER
20511 Productivity 50 False
20511 Cash per Hour 30 False
20511 Quality 0.9 True
21320 Productivity 60 False
21320 Cash per Hour 45 False
The non-modifier KPI scores are summed together and multiplied by the modifier score (any KPI where Modifier is marked true)
So in the example table above, user 20511 would have their Productivity and Cash per Hour scores summed to give 80 and this would be multiplied by the quality score of 0.9 to give 72.
An extra complication is that not all users have a modifier so I've been using a default modifier of 1 in this case.
So far I've come up with the below query
SELECT
[userID],
sum(IIF(Modifier = 0,([Score]),0)) AS summedScore,
IIF(sum(iif(Modifier = 1,([Score]),0))=0,1,sum(iif(Modifier = 1,([Score]),0))) as modifierScore,
summedScore * modifierScore as finalScore
FROM tbl_KPIScores
GROUP BY UserID
Which feels quite clumsy and also fails if the modifier score is actually 0. Is there a simpler way to do this?