Forum Academy Marketplace Showcase Pricing Features

Displaying the average of 30 days of user inputted numbers, retreived from database

Can someone help with this? I have a form where I enter 30 days worth of numbers. I want to return/display the average of those numbers. I cant figure it out. thanks!

Difficult to say without seeing what exactly you’re doing, but if you’re saving the data to the database, you should be able to just sum it all up and divide by 30. So just have a text field set it’s value to the total of the values / 30.

If you’re not saving to the database, you could just keep a running total as a custom state on your page or group and when done, divide by 30.

Thanks for the response… I am saving to the database, but was having trouble understanding the steps needed to get the value into the text field (to then values/30). Can you help me with that?

How are they saved to the database? For example, if it’s a number field in a Thing and you have 30 Things, the text expression would be “search for Thing’s number field :sum / 30”

Depends on your data structure, so if you share a few more details, we can help get the specific expression right for you.

certainly, does this help?

So every day, for 30 days, a new record with those fields gets saved?

It’s not clear to me from your screenshot, which of the number fields you want to do the average calculation on.

In my app, a note-taking app, I do something similar - I display the average note size for a user and it looks like this:

You may find it useful.

Sorry, So every day a user inputs a number todNum. I would like to understand the steps needed to display the Sum of the inputs divided by 30 ( Actually even better, divided by the number of inputs )

So if each day the user inputs 100, on day 30, the output would be (3000/30 =) output display 100.

or divided by the number of inputs so on day 7 sum/7 or day 11 sum/11. Am I making sense?

Yes, actually everyday a new number is saved, and ideally i would like to sum/divide to get the average for every input, so day 7 would be sum of 7 numbers divided by inputs 7. or 10 etc. etc.

“Do a search for” for the type of object, with the constraint of “created date > current date:+days:-30”, then select the field of interest, then :avg.

1 Like

I think you would be better off doing the calculation when you save the numbers, rather than when you want to display it. So save the average when you save the number.

As Scott says, :avg is the one the use.

Awesome Help! Thanks to each of you for your responses. Using them I went back and discovered there is more functionality than meets the eye. Here is what I did…

constraint: createdBy = Current User < Picks the current users data from the db.
Appearance: Search for MyDatabase’s TodaysNumbers:average < This is better than my first idea of 30 days.

I just found this site last Wednesday, have had an idea for an app for a while so thought I would give it a try. I really like it.

Is there anyway to see your app’s data so you can learn whats going on? for example if you were to write the code in java or some other language?

Click on the data tab on the left side of the screen.