Can I use a formula to perform a group by operation?

Hello,

I want to calculate the total amount of calories that I consume in a day. I already have table that calculates the calories for each meal.

Is it possible to create a formula - maybe in a new table - that takes the sum of all meals on a certain date? I already tried sum() and filter() but I cannot point out that the filter condition is the date

Hello @frederikdc, have you seen this template: Personal Health Log // Baserow? In the table, Daily tacker, column Total Calories + Macros calculates the daily amount of calories consumed. It differs a bit from your approach though.

Regarding the formula for your specific use case: I don’t think it’s possible in Baserow, but let’s also ask @nigel if there are any ways to calculate calories consumed on a certain day.

1 Like

Hello Olga,

Thank you for the quick reply. I checked the template and it is very similar to what I want to achieve, but the major difference is that I have a column amount with the number of grams that I consume of a meal. So, my calculation needs to take this amount into account which makes it impossible to use the same approach as in Daily tracker table.

However, after taking a look at the template, I realise that I might solve the issue with an intermediate table that links a meal with a certain day.

Hey @frederikdc

However, after taking a look at the template, I realise that I might solve the issue with an intermediate table that links a meal with a certain day.

That’s right! If you create a new table where you have one row for each day you can then link to the Meals table and add every meal for that day to the row. At that point it should be simple to just sum up the calories via a lookup field and a formula field.

If you do it like that, you can also re-use meals that you eat frequently :slightly_smiling_face:

1 Like