Sum over calculated field

Screenshot 2023-07-17 at 2.25.21 PM

I have the above visualization in my quicksight
PASSED & FAILED values are calculated field filtered out from other dataset, involving ‘distinctCountOver’ and ‘ifelse’

However, whenever I collapse my table, the total/count doesn’t provide the exact output I wanted as shown in the desired output

How can I achieve this?
Or is there a way for me to created another calculated field to output the total sum for each class?

Thank you

Have you looked into PRE_AGG calculations?

I believe that’s what you are trying to do.