# 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.