Math in multiple fields on the same record
Hi guys,
I have a data base structure where there is 8 fields as doubles and one text field.
When I query the records, I would like to calculate an average of the 8 fields.
I tried to create a new variable starting with 0 and set up a function stack to add numbers. When I put the value to be added like db.field I got an error message telling that the field should be a number.
I'm not sure if I'm the right field notation. What I need to add the information store in the field.
Any clue on what I'm doing wrong?
Thanks
Gustavo
Comments
-
If you share a screenshot, I think we could be more helpful!
-
Sure.
I query all results from the record wheel. Than create a variable AVG that should add the value of the fields.
-
Most likely you are returning a list in query all records, and so references to that list get you arrays of numbers rather than thenumbers themselves. Is the query supposed to return multiple records? If so, you might try setting up a for-each loop to generate the averages for each record inside that.
This multidimensional data manipulation is a frequent topic on Statechange daily office hours and loom-enabled forums where we teach you to crack the hardest 5% of projects.
-
So far, I have only 1 record. The addition I’m doing is to pick fields from this record.
-
Yes, but is the output type "list" or is it "single"?
You can have a list that contains one record - it's like the holding an apple, vs holding a plastic bag that has one apple. You'll notice the difference when you try to take a bite.Check the output tab of your "query all records" - you can change it there.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback