How do I do this math without Google Sheets?

I want to build an app with Glide where I can do the following. I add rows where I have a column with the day and a column with an amount of hours. After that the users can add up the hours between two dates bij selecting a start and an end time. How do I do this?

This is the answer of ChatGPT but I want to do it in Glide Tables only :wink: How to do it? Or do you have example apps?

Let’s assume you write the user selected Start Date and End Date to two user specific columns.

  • Start by adding two single value columns to your table that contains the data: one for the start date and one for the end date. This will apply those dates to every row in the table.
  • Now add an if-then-else column:
    – If date is before single value start date, then null (leave empty)
    – If date is after single value end date, then null
    – Else amount of hours
  • Now do a rollup->sum on the if-then-else column to get the total number of hours between the two dates.
2 Likes

Thanks, I’m going to try that!

Sorry @Darren_Murphy extra question.
Say if I want the admin to be able to this too, I need another solution, right?

No, that’s a general solution that should work for any user.

Did you need the result to be filtered by the current (signed in) user? (you didn’t say that you did)

1 Like

I didn’t say it and I didn’t mean it :wink: !

Sorry to ask stupid questions, but where do i get the data for the two single-value columns (start date and end date)? I never really understand this concept. Well I sometimes do, but not here.

Whichever table/row you write those start and end dates to would be the table/row where to point the single value columns. I assume you would have date pickers somewhere in your app, and those date pickers write to a certain table/row. That’s where you want the single value columns to retrieve those values. Then the single value columns will populate the same value on every row.

Ah so I have a column StartDateRow and a column SingleValueStartDateRow for example?

Yes, exactly. Assuming you have a date picker that populates a start date in the first row of a table, then you can use the single value column to take that value from the first row and populate it across all rows.

The idea is this, I have different people / companies adding hours / money they put in a big project.
I want to be able to calculate the amount of hours / money in a period per company.
I want to be able to choose that period by picking start and end date. And then do the calculation.
So I have a growing table with rows with work / money done by people for different companies.

Then it doesn’t feel like I can use the first row, am I right?

You can use any table you want. You could have a single row table that serves as the driver for your screen or tab. In the table you could have 2 user specific columns to hold the start and end dates, as well as a rollup column to sum hours from an IF column in the project table. In the project table, you would have 2 single value columns and an IF column as @Darren_Murphy described above.

You can also use the same table if you choose. There are lots of ways to get the same result.

2 Likes

Then to me a StartEndTable feels most logic!

1 Like

@Jeff_Hager @Darren_Murphy I’ve got it up and running the way I want it and I understand what I’m doing! Thanks do much!

2 Likes