A user can vote on these numbers:
1, 2, 3, 4, 5
Then it's displayed as groups like this:
1 - 5 votes
2 - 3 votes
3 - 1 vote
4 - 17 votes
5 - 2 votes
Now I want the avarage rating score, like 3.9 or whatever it will be.
What I tried and failed:
Multiply all rows in the groups like:
1 - 1 * 5 votes
2 - 2 * 3 votes
3 - 3 * 1 vote
4 - 4 * 17 votes
5 - 5 * 2 votes
and then a sum of them where I get 52. Then I divide it with 15 which is the sum of all the valid scores. 52/15 = 3.46.
If I do that with the same votes on each, I can see how this is not correct:
1 - 1 * 1 votes
2 - 2 * 1 votes
3 - 3 * 1 vote
4 - 4 * 1 votes
5 - 5 * 1 votes
The result with my way would be 15/15 and that's 1 but it should be 3 in this case.
Any ideas?