You could try doing something like default(splits, 1) as divider
where it would use splits
if it has a value, and 1
in the other cases, this should allow you to do cost / divider
to get your personal cost. After doing that, you should also be able to group the query and do a sum(rows.personalCost)
to get the total sum of those. Does this make sense?
Another option related to summing up the totals has been posted in the thread below, where we add a row to the original table after summing up some columns. You’d need some tinkering related to selecting the correct field, and to adjust the new row with empty columns for you multi column table. In general you shouldn’t to know a lot of javascript though.