Best approach to show monthly summary in Expense Tracker app

Hi everyone,

I have recently started playing around with Glide and really appreciate this support forum. I have built a simple app to log our expenses for the month. It currently have only 2 tables - Categories and Expenses. Everything works fine so far, but I would like to add the following features:

  • A Component showing the total sum of all expenses for the current month.
  • A Chart showing the total amount for the different categories for the current month.

Before I start building this I would like to ask for your opinions of the best approach to this. Also, I have been trying to understand use cases for the new Query column but I don’t really understand it fully yet, is that something that I could use in a case like this? If not, then I am happy to learn about other approaches to this.

My suggestion:

  • Create a math column in your Expenses table using the following formula:Year(Now) * 100 + Month(Now)

  • Use the current date/time (Now) as a replacement value

  • Create an identical math column, but this time use the Expense Date as a replacement for Now.

  • Now create an if-then-else column:
    – If first math column equals second math column, then Expense Amount

  • Finally, create a rollup column that takes a sum of the if-then-else column

You can make good use of the Query column for this one. Create the following in your Categories table:

  • Start with a Query column. Point it at your Expenses table and add two filters to it:
    – First math column equals second math column (the same two columns as above), AND
    – Expense Category is This Row → Category
  • Create a rollup column that takes a sum of the Expense Amount column via the Query column.
  • You should now be able to use your Categories tables as the source of a chart.

The documentation for this was added a few days ago, and it contains a few example use cases. Maybe that will help?


Excellent, let me try to build this out right now. Will get back with the result :slightly_smiling_face:

This worked great! And I finally understand how to use the Query column, it seems like a relation column with filter options :slightly_smiling_face: I already had a relation to the related expenses so I could set up the Query column through this relation which I assume can speed things up when there are many records. Thanks so much for helping me with this!

1 Like

Yeah, kind of. Although you’re not actually matching two columns like you do in a relation. If you’ve ever used SQL, it’s more like that, eg: SELECT * FROM Table WHERE [CONDITIONS] ORDER BY Foo LIMIT n;

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.