I have a fairly basic Pipedream custom function that adds up the total
of all the items that match an arbitrary list of categories (items of expenditure that come under the heading of 'food'). But it gives an
error if any of the categories in the list are not found in the input, because the lookup function fails.
Typical usage:
edibles(array1,array2), where array 1 and array2 are non-consecutive
database columns containing categories of expenditure (e.g. Transport, Grocery, Clothes) and totals spent under those categories. I just want
to be able to add up the subtotal of the amount spent on edible items specifically.
But how do I 'blank' the input so that a non-existent category is
counted as having a value of zero, rather than throwing an error?
Currently I have to manually add an extra row to the input arrays, e.g. "Dairy", 0, in order to suppress the error when in occurs.
I feel that it ought to be possible to have some kind of 'if' option
that would return zero if the lookup fails, but I can't work out a way
of doing it.)
=================================
Add up the total value of all the entries in array 2 which correspond to entries in array 1 that match one of the text values specified in this function. ------------------------------------------------------------------------ ...function("edibles","categories:array","prices:array") ...lookup(C7,@categories,@prices) Dairy ...lookup(C8,@categories,@prices) Greengrocery ...lookup(C9,@categories,@prices) Grocery ...lookup(C10,@categories,@prices) Meat
...result(sum(A7A10))
In article <50d0090c5c.harriet@bazleyfamily.co.uk>,
Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
I feel that it ought to be possible to have some kind of 'if' option
that would return zero if the lookup fails, but I can't work out a way
of doing it.)
=================================
Add up the total value of all the entries in array 2 which correspond to entries in array 1 that match one of the text values specified in this function. ------------------------------------------------------------------------ ...function("edibles","categories:array","prices:array") ...lookup(C7,@categories,@prices) Dairy ...lookup(C8,@categories,@prices) Greengrocery ...lookup(C9,@categories,@prices) Grocery ...lookup(C10,@categories,@prices) Meat
...result(sum(A7A10))
I think you need to use dsum()
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 05:12:14 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
921 files (14,318M bytes) |
| Messages: | 264,602 |