SETUP: Users rate products based on different criteria and these ratings (option buttons values 1 to 5) are converted to a star rating with an average value at the end for the whole product.
The approach I used was to count the number of rating criteria (questions) per product and divide the sum of the criteria rating values with the count. This gave an average value.
It now seems that the users would like to choose to keep some values blank, i.e. select "not set" when faced with the option buttons, but not to always do so. I have that working fine, but the members would also like to see an average value for the overall rating and I cannot figure out how to get a count of ONLY the filled values (eg a value greater or equal to 1) and use that to divide the sum.
This is the code I have so far:
As you can see, that is looking terribly clunky and I wondered if there was a way to get the count instead of all the if else steps (which will be horrific if more than 2).