0

Below is a screenshot I have of a sample MySQL attendance data for users.

Each attendance for username is calculated based on column attended_sessions divide by total_sessions multiple by 100. This gives each users exact attendance. Each user has variable total number of sessions depending on when they started and ended.

This is fine. However my question is to calculate the attendance for all of those users, and this poses a maths dilemma.

If I average all 15 rows of the attendance percentage I get 87.09%. However, this is average. Whereas if I sum up both the sessions data I get attended_sessions=1494 and total_session=1648. Then if I divide that by each other and multiply by 100 I get 90.66%.

My maths skills isn't great. So which is the correct method to calculate? I would think that the average isn't accurate as it is averaging it. Whereas the other method of summing up all sessions would be the exact representation of the attendance.

enter image description here

0

1 Answer 1

1

Summing the sessions data, dividing and multiplying by 100 is going to be more accurate than just summing the attendance averages. The values for attendance are already rounded, so you've already lost some precision. Better to work with source data than derived data.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, I was thinking the same. But even if I don't round the attendance column for each user and then average that, I still get around 87.09ish % I am assuming this way will be average across all users whereas summing the sessions columns, dividing it and multiplying by 100 will actually be an overall attendance and not a average is that right?
It doesn't matter if YOU do the rounding, the values in that column have already been rounded by the database. Take the first record: (101/108)*100 = 93.518518(repeating), but the value in the attendance column has been rounded to 93.52.
Thanks @digital.aaron I understand, but what I meant was that I have the ability to store the data in the attendance column as 93.518518. It's just in the above example it has been stored in rounded format. So, you suggest the session data will be a more accurate representation of the entire attendance instead of averaging each? I guess if each user is being calculated like that then only makes sense to calculate the overal the same way.
That's correct, using the add->divide->multiply technique on the raw session data will give you a more accurate answer than averaging the rounded average attendance values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.