Groups | Search | Server Info | Login | Register
Groups > comp.sys.acorn.apps > #19417
| From | Harriet Bazley <harriet@bazleyfamily.co.uk> |
|---|---|
| Newsgroups | comp.sys.acorn.apps |
| Subject | Re: Pipedream lookup error in custom function |
| Date | 2025-04-13 18:14 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <b986030d5c.harriet@bazleyfamily.co.uk> (permalink) |
| References | <50d0090c5c.harriet@bazleyfamily.co.uk> <5c0cdfa5f8news*@Torrens.org> |
On 13 Apr 2025 as I do recall,
Richard Torrens (News) wrote:
> In article <50d0090c5c.harriet@bazleyfamily.co.uk>,
> Harriet Bazley <harriet@bazleyfamily.co.uk> 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.
Back to comp.sys.acorn.apps | Previous | Next — Previous in thread | Find similar
Pipedream lookup error in custom function Harriet Bazley <harriet@bazleyfamily.co.uk> - 2025-04-11 20:46 +0100
Re: Pipedream lookup error in custom function "Richard Torrens (News) <News@Torrens.org> - 2025-04-13 11:42 +0100
Re: Pipedream lookup error in custom function Harriet Bazley <harriet@bazleyfamily.co.uk> - 2025-04-13 18:14 +0100
csiph-web