Calculate the cost of training session based on a global (editable cost)

Hi everyone,

Trying to build my first Glide app after seeing an article about it on “how easy” it is (it was kind of a lie). Anyway, what I want is rather simple.

I am having PT sessions every month. I want to have a button that I press to record a new session. (this was simple - button → action → add current date to the date column).
I have two tables: sessions / settings. In sessions I want to keep the session data, in settings the global data.

Now the math is simple → # of unique sessions days between the 11th of previous month to 10th of current * session cost.

I tried using openai/perplexity to find answers, I tried googling…but I failed. I find it too difficult to simply get the multiplication done, and filter it by the correct time filter.


This is what I would like to have. (right now that 100$ is hardcoded text :P)

Thank you!

Can you show how your data is structured? Do you have a start and end dates stored in one of your tables? If you do, then I’m thinking what you need is a Query column to find the sessions within that start and end dates, followed by a Rollup column to count the number of sessions in the query. Then you can use that number in a Math column.

Right now as mentioned I have to data tables session/settings with a column each. one for Dates, and one for the global price.

I thought similarly as you mentioned, but I find it a bit difficult to count distinct dates.

If you show us what your data table looks like, with the column headings visible, we can almost certainly give you step by step instructions.

1 Like



Tried importing the cost from the settings tab to the sessions and then I wanted to do a in a Math column the total for the month based on QCost( which is a query lookup in the settings table)

Okay, just going back to your original question, you said the “Total Cost” should amount to $100.
But I don’t see how that would be calculated based on what I see in your data tables?

Putting Glide aside for one second, can you tell me how that should be calculated?

As mentioned, the 100$ you see there is hardcoded text. what we have in the settings table under session cost, is what should be used to calculate.

number_of_sessions_in_a_month * session_cost = total cost.

Oh, right. So the $100 wasn’t based on the actual data.

Okay, so that’s pretty straight forward.
First thing you can do is replace that Lookup column in your Sessions table with a Single Value column. Target it at your Settings table and take “First → Session Cost”. You can then do a Rollup on that column to get a total cost for all sessions. (The result should be $350).

To breakdown by month, I need a little more information on your goal. For example, do you want to:

  • Select a month and show a summary for that month?
  • Show some sort of month by month breakdown in a table covering several months?
  • Something else?

All of the above (and much more) is certainly possible, just need to be specific about the goal :slight_smile:

1 Like

I changed as you mentioned the Lookup to single value → “first”, and added the rollup as you mentioned. It seems you need to define it as number for “sum” to appear, it doesn’t auto detect. That was confusing for me at first.

For your last question, I want to show the current month cost under the total as displayed in the first post. Though now that you mention it, it would be beneficial to also see the previous month cost total as well.


As mentioned this app is meant to be super basic. I will want to eventually add more features, but I need a starting point and to understand some of the functions (for instance the fact that I can’t do a rollup sum)

I also want to thank you for the help you have given me. I appreciate it a lot!

Yes, that’s correct. You can’t sum a text value. Well done on figuring that one out, it’s a common trap :+1:

Before I offer a solution, I have some more questions. There are multiple ways to approach this, but the preferred approach will depend on answers to these questions:

  • Will the Session Cost ever change?
  • If it would change, what would you expect to happen with the cost of past sessions? (ie. should they keep the original cost, or adopt the new cost?)
  • Does your App require sign-in?
  • If your App does require sign-in, do you have a Users table with User Profiles properly configured?
  • Are you the only user of your App?
  • If there are other users, should they also be able to view these monthly summaries?
  • Will the Session Cost ever change?

Yes, and I made it editable.

  • If it would change, what would you expect to happen with the cost of past sessions? (ie. should they keep the original cost, or adopt the new cost?)

Ideally they wouldn’t change, but considering the scope of this app(for personal use), it doesn’t matter if they do change.

  • Does your App require sign-in?

No, it is just for me and another friend who will use this app for sport cost tracking.

  • If your App does require sign-in, do you have a Users table with [User Profiles] properly configured?

I do have a user table, but I don’t plan on using it for anything at the moment.

  • Are you the only user of your App?

Just a friend and I will use the app.

  • If there are other users, should they also be able to view these monthly summaries?

Yes, everything should be identical between the users. Permissions/views/etc.

Okay, well my suggestion would be to add the cost to the Sessions table as a static value when each row is added. Then it won’t matter if the cost changes in future.

For your “This Month//Last Month” totals, I would suggest the following approach:

  • In whichever table is the source of the screen where you want to display this, create a Math column using the following formula:
Year(Now)*12
+ Month(Now)

In the above, use the special Now value as a replacement for Now. This will give you an integer representation of the current month

  • Create a second Math column for last month, subtracting 1 from the previous column
  • Now in your Sessions table, create an identical Math column as the first one above, but this time using the Session Date as a replacement.
  • Back in the first table, create a Multiple Relation column that matches “This Month” with the Math column in your Sessions table.
  • Do a Rollup->Sum to get a sum for this month
  • Create a similar pair of columns for Last Month

Give that a try and let me know how you get on.

1 Like

Everything is stored in the same datatable, so I don’t think the relation part is required? Or am I wrong?


This is how it looks right now.

You appear to have one too many math columns, you should only have three, as follows:

  • One to get a number representation of this month
  • One to get a number representation of last month
  • One to get a number representation of the Session Date

Yes, you do need the relations. I’m not sure what your rollup columns are currently targeting, but they’re obviously wrong. The purpose of the relations is to filter the rows based on whether they are this month or last month, and then you do the rollups through the relations.

Hmm… Even so, I’m confused on what to do with the relation column and how to set it up. Like this?

these are the current columns I have:



This is what I understood based on your comments, please let me know on how to proceed :slight_smile: thank you!

Your error is in the last screenshot. You are targeting the relation via the table. This is wrong. You need to target the relation directly. When selecting the target, pay close attention, you will see it in the list.

Is this correct @Darren_Murphy?

I know it’s unconventional, but think about it :slightly_smiling_face:

1 Like

Hmm, I guess it does make sense.

For some use cases, it saves a bunch of complicated math

1 Like