I have 4 fields in my DB that are part of my page data type
Value 1
Value 2
Value 3
Value 4
On each page I wan to find the average of the 4 values.
I can do “This page’s value 1 + This page’s value 2 + This page’s value 3 + This page’s value 4 / 4” but the problem is that I don’t always have 4 values entered. Sometimes the user enters 2 or 3 values only, so how do I find the average of the values entered?
How do I best deal with values getting deleted. Once they are in the list, and I delete the value, it still stays in the list. How do I correctly identify input value 1 from input value 2 when deleting the value.
value 1 plus value 2 plus value 3 plus value 4 divided by 4
or value 1:converted to list:plus item value 2 plus item value 3 plus item value 4:average
But if you’re having to average like this, it indicates inefficient DB structure as they should be a list of numbers or a new data type entirely.
If a user needs to be able to enter a list of numbers to average them, you should be having a repeating group that’s a list of numbers, then a button that allows them to add a new number to the list and a delete icon to remove existing numbers.
Then you just do Repeating Group’s list of numbers:average.
The second suggestion, the type is a number, so I can’t find the converted to list option.
It’s an input field, so users need to enter numbers and I’m looking to dynamically calculate the average of those numbers. It could be 4 numbers or 3 numbers, or the user could enter 4 numbers and delete 1.
The below is an excel representation of what I’m trying to achieve. Basically the average dynamically changes even when values are added/removed, and I need to have 4 input fields
To an extent. I have 4 input fields only, so it has to be limited to just 4 fields, and there has to be 4 input fields, instead of just the one input field you have with a button.