How do I Sum If?

New Day, New Question :smiley:

I have the following Table:

Now First I have Test Times, which is basically just a link to table, to do lookups, second I have times, which lookups all times that I entered in a specific table and is linked to a certain employee. So EMP1 has 5 time entries, therefore lookup field “Times” shows me 5 different values. Lastly I have the field “Billable”, which is a Bolean field in the original table and basically just shows if a time entry is marked as billable or not (If billable Bolean field is marked by a check sign). So you see there are 5 times, the first four are checked and the last one is not checked. Is there a possibility to sum only the times that are checked and if yes how?

I already summed all time entries, but I want to sum only the money that are marked as billable in the Boolean field as well.

Thank you so much and kind regards,

Tom

Hey Tom :slight_smile:

This is possible by using filter.

You can do something like this:

sum(filter(field('Times'), field('Billable?') = true))

Or in short:

sum(filter(field('Times'), field('Billable?')))

This basically filters the field Times based on if Billable? is true and then runs sum over the items remaining.

That should do the trick?

FYI, you can also do this without the lookups if you don’t need the lookup fields in that table for anything else. You can replace field in the formula above with lookup and it will lookup the value from the other table using the formula.

1 Like