Very new - Compare Data

So trying to wrap my head around how data is used and slowly getting there. Taking a bit as I am used to relational apps.

So my question relates on how to pull past data to compare to existing data? Example: I weigh in on Tuesday at 185 and the following week I weigh in on Monday at 190. How would I build something that pulls the last weeks weigh-in data and then compare to this weeks weigh-in data?

Thanks

Hey Sean :slight_smile: Welcome to the Forum!

You can start this by creating a new data type called “WeighIn”. Within the WeighIn data type, there could be a field called “Weight” (Type: Number, List: No). By default there will be a Created Date field (date), but if you’d like the User to be able to select a custom Date, then you can have a second field called “Date” (Type: Date, List: No).

On the page itself, add an input (set the type to decimal or integer) for the Weight field, and add a date/time input element for the WeighIn’s date. Then place a button next to those which will be responsible for creating the WeighIn entry (Thing) in the database.

For example, when Button “Submit Weigh In” is clicked, the action is: Data → Create A New Thing → Thing: WeighIn
Fields:
“Weight” = Input weight’s value
“Date” = Date/Time Input’s value

Then add a second action → “Reset relevant inputs” to clear the data from the inputs.

Once you’ve tested this once in preview mode, you can go to the Data tab → App Data → WeighIns and the WeighIn entry will show.

If the User is logged in, the Creator will automatically be stored as this User.

If you’d like to view a User’s WeighIns, there are a few ways to do this - but most simply would be to have a repeating group. The type of content would be WeighIn, and the data source would be Do A Search For WeighIns, with the constraint being Created by equals Current User. Sorting the results by Created Date descending = yes sorts the results from Newest first to Oldest. (Selecting descending = no would sort the results from Oldest to Newest).

Place two text element insides the repeating group cell to display the weight and the date text fields for each Weigh In. This could be displaying in any way you prefer, but the dynamic expressions would be “Current cell WeighIn’s Weight” and “Current cell WeighIn’s Date”.

If you have any questions feel free to ask and we can definitely assist. There are more ways that the above to display and compare the data, but this would be one way to get started. :slight_smile:

2 Likes

Wow! Thanks so much for that detail! I am almost there.

What I am trying to do is take weight from one date and subtract it from another weight from a different date to get weight lossed/gained.

Thanks for any assistance.

Sean

Awesome! No problem at all. :slight_smile:

If you were to do something simple such as, Start weight - Current Weight, the expression could be:

Search for WeighIns:firstitem’sWeight [This is the User’s Current Weight]
*Here the Sort by Created Date is “yes” to get the most recent Weigh In Weight (the newest Weigh In Weight)

Subtract

Search for WeighIn:firstitem’sWeight [This is the User’s Starting Weight]
*Here the Sort by Created Date is “no” to get the User’s starting Weigh In Weight (the oldest Weigh In Weight)

In preview mode if a User weighed 150, and then the next day weight 145, the text would display like this:

If you wanted to be able to show the difference from Weigh In to Weigh In inside the repeating group, I would recommend creating a new field within the Weigh In type called “WeightLoss/Gained” (Type: Number, List: No)

Then you can calculate this field’s value in the workflow every time a new Weigh In is created:
*Here the value of the WeightLoss/Gained field is calculated by subtracting the Weigh In that was most recently submitted by the User (not the one by created now), from the Input Enter Weight’s value now being submitted by the User:

In preview mode it would look like this:

If you go to plugins, you can also install the graph/chart element plugin which would be useful for displaying Weight over time. :slight_smile:

1 Like