On 13 Apr 2025 as I do recall,
Richard Torrens (News) wrote:
In article <[email protected]>,
Harriet Bazley <[email protected]> wrote:
[snip]
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()
Hmmm. dsum() is what is creating these summary blocks in the first
place (listcount to analyse the categories present in a very long list,
then dsum() replicated downwards to add up the values corresponding to
each of those categories).
But I don't see how to use it to look up the numeric value in one array corresponding to the textual value in a parallel array....
All I actually want to do here is to add up an arbitrary subset of the
values, but where I don't know in advance which values are necessarily
going to be present or which rows they are going to be located on -
since that depends on the output of listcount().
So I might have a block that looks like
Dairy 1 0.59
Entertainment 2 61.50
Greengrocery 5 64.95
Grocery 4 17.00
Household 1 5.00
Meat 3 12.60
Music 2 508.76
Postage 1 3.95
Repairs 2 271.00
Transport 1 3.50
Utilities 5 146.27
or one that looks like
Entertainment 1 10.00
Greengrocery 5 81.91
Grocery 3 11.00
Insurance 1 124.09
Meat 2 15.50
Music 2 110.00
Tax 1 226.85
Utilities 5 128.24
but I want to return the sum of the values for however many of Meat,
Dairy, Grocery and Greengrocery happen to be present.
--
Harriet Bazley == Loyaulte me lie ==
Sir Francis Drake circumcised the world with a 100-foot clipper.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)