I can’t quite believe I haven’t found this in a search, so forgive me I must be cocking up the search input.
I have a very simple app that tracks the mileage on my lease car.
I’m trying to have a form where the user simply enters the current mileage - the date field is pre-populated with “now”:
It adds a new row correctly but only populates the Date and Actual Mileage columns.
I want to update the columns Origin Date (to the standard “26 August 2022”), and then calculate Date Diff, Target Mileage, Old Mileage, Change, and Spare Miles.
I assume I need to add these columns to the “additional columns” part of the form, but I don’t see how to do that?
And then, once they’re added, how do I trigger the calculation function of those columns to update that row entry?
As a cherry on top, the form seems to persistently keep the “now” date in the field unless I physically close the app and re-open it. Can I reset it to update whenever the form is visible?
If that’s a fixed date, then there is really no reason to add it with every new row. Do you have User Profiles configured? Assuming yes, then what I would do is add a datetime column in the Users table, add that date to it, and then you can refer to that directly in your calculations without even needing that column in your Miles table.
You don’t need to add data to computed columns, and in fact you can’t. Computed columns will automatically calculate for each new row that is added. If you understand how arrayformulas work in spreadsheets, it’s a similar concept.
I’m not sure I understand. Are you saying that the now value doesn’t change?
Can you show me how you configured that date picker component?
I don’t know how you split my question up and answered parts of it, but it’s very cool! So maybe you would be so kind to explain that to me as well?
Anyway, the Origin Date column and your suggestion was the key to my problem! By adding the single value to my Users Profile, it solved everything and the calculated columns updated as expected - It was that value not being populated that prevented any other columns from calculating. Thank you so much!
For the Now (actually Today) problem, see my config screen below:
I’ve set the default value to Today which I expected to update every time I visited the form screen. However, if I make an entry today on the app, and then go to the form tomorrow, that field still says 28/12/2024. I have to actually close the app on my phone (swipe it up and away) and re-open it to get the correct date.
I’ve just noticed that if I clear the date that’s already populated by using the ‘x’ in the field, and then go to a different screen and then back to the form, it populates correctly. So do I need to do something to clear that field after the form submission?
Excellent!
Just one thing that occurred to me after posting my previous reply - would that date ever change?
If it’s always going to be 26 August 2022, then what you have now is fine. You just need to be aware that if you ever changed that date then every row in your Miles table would instantly recalculate based on the new date. If you need to cater for that changing, then I can offer an alternative solution.
To be honest, I’m not really sure what’s going on there, sorry. The behaviour seems a bit odd. I don’t often use a Form Container, so perhaps there is something special about the way that behaves that I’m not aware of
No, it’s the date I received the car - I just need to know that I’m on track not to exceed my 10,000 miles per year agreement so I’m calculating against the days since I received the car and the current date to give me the expected total miles for today. (Obviously, I can go over as long as it’s under 30k after 3 years - this app is just a guide)
The workaround of deleting the value and then switching screens is fine for now - I’ll play with it some more to see if I can figure out a more elegant (proper) solution and post it here if I find it.