Peter,
Sum works fine on a selection of records or on an array. It used to be a
little slow but not now.

If you are working on 4D server it's useful to build some functions that
will run on the server to speed things up even more. Using your example you
could write:

// Customer_get_invoiceSum (id)
QUERY([INVOICE];[INVOICE]customer=$1)
$0:=Sum([INVOICE]amount)
UNLOAD RECORD([INVOICE])


Set the Execute on server attribute and use it as

$total:= Customer_get_invoiceSum(2)


If you are actually on a server this will not change the selection of
invoices on your client machine.


On Wed, Apr 12, 2017 at 4:22 AM, Peter Jakobsson via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi
>
> Occasionally I’d like to use the “Sum” function on a current selection but
> am hesitant because of distant memories of it only being supported in
> certain circumstances (e.g. in reports, on single user.not client server
> etc).
>
> Do people use this outside of a report context and on any current
> selection ? e.g. can you safely just do this…
>
> QUERY([INVOICE];[INVOICE]customer=2)
> $total:=Sum([INVOICE]amount)
>
> Is anyone aware of any circumstance where this won’t work ?
>
> Thanks in advance !
>
> Peter
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************




-- 
Kirk Brooks
San Francisco, CA
=======================

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to