The values in an array can be summed using:
=SUM({1,2,3})
But is there a way to exclude certain values from the sum if they are outside some limiting range? In other words, an equivalent to:
=SUMIF({1,2,3},">1")
Unfortunately the above doesn’t work since, unlike SUM, SUMIF supports cell ranges only, not cell ranges and arrays. (Well, technically SUMIF in Google Sheets and Zoho Sheets supports both, like SUM, but that’s not the case in LibreOffice Calc.)
I should clarify that the array {1,2,3}
is actually generated by a fairly complex expression, something like:
IF(E21>$B$23:$B$28,$B$23:$B$28,E21-$B$22:$B$27)*$C$23:$C$28
So any practically useful solution should really avoid repeating the expression that generates the array since that would violate the DRY principal, making writing, reading and editing cell formulas much more error prone and difficult.