A way to do a SUMIF in an expression?

I have a main table with dollar value columns, and underneath it a totals table who’s data is just the SUM() expression of each column.

My main table also has a check box column, and I would like it so that if a few items are checked off, I only SUM those items instead of the whole row. Is there a way in expression bindings to do this, basically the equivalent of a SUMIF in excel?

Doing this in expressions is probably the wrong way to do it, in my opinion. I would make a pretty generic Python function and just use runScript; or, if you can avoid it entirely, property change/etc scripts directly.

Expressions aren’t well suited to handle datasets, since they lack any intermediate state operations (variable assignment) or looping operators.

1 Like

That said, a sumif() expression function could go into an ideas post :slight_smile:

1 Like

Ok. I was afraid of that since it’s already all built with expressions, but a runScript would help me keep it in the same structure. Thanks.

I don’t suppose there’s a way to filter by a column to a dataset first in the expressions, or a cross-product ie column1 x column2 = result - that would also work given the 0 and 1 booleans on my check columns. I don’t see any off the bat but I know a lot of people here are very creative.

Not in expressions, but certainly doable in scripting.

+1 on doing this with a propertyChange script.

Of course, very little is not able to be done with scripting. I just enjoy when things can be done cleanly (or just cleverly) with expressions though. Guess its off to scripting I go.

This is trivial in my view() expression function:

view("SELECT max(valuecolumn) WHERE booleancolumn GROUP BY 1",
    {Root Container.path.to.dataset})