Sum values (Excel sumif)

Hello,

I have a table called costs which has two columns: costs and company. The company values come from another table called company. I can add a cost record so the data in costs has a record for a cost value and a company. For example:

Company 1 - 30
Company 2 - 40
Company 1 - 60

I would like to add up costs from a specific company.

Currently I’m using a text field, Insert dynamic data, Do a search for, selecting type Costs (table from above), trying to add a constraint of company = “Company 1”, but I can’t. I would then use :sum or mathjs to continue the calculation. I was expecting to be able to type Company 1 after the =, but I can’t get it working.

I’ve managed to do it by having another column with field type yes/no called company 1, but this doesn’t feel right. I’d then have to have a column for each company?

Many thanks,

Felix

Just type inside the grey search box…Text will change to blue (if company field is text)

thanks but company field isn’t text, it’s a referance to another table, called company.

Try to do another “do a search for” Company, within the “do a search for” costs

Hi Robert, thanks for getting back to me. I tried your suggesiton of putting do a search for “company” but I couldn’t get that to work either.

I created a quick app to share. https://bubble.io/page?id=sumifquestion

Many thanks,

@felixw Check it out now.

Thanks Robert. I was hoping to be able to do it without requiring to select the company via an input if that’s possible. (I’ve unchecked “this item is visible on page load”, but this feelslike a crude whay of doing this?)

Many thanks for your help.

Felix

Yes, this can be done. I’ve changed it in the second grouping for comparison.

Basically, you just need an input (disabled), set to the initial content you want, and that will serve as the company for the search constraint.

Ah brilliant thank you Robert! I see how you’ve done that and it makes complete sense. Can’t believe I hadn’t thought of doing it like that already!!

1 Like

Glad to help out. If you could, mark my previous post as “solution” so it can help others faster.