Page 1 of 1

Summation by condition

PostPosted: Fri Jun 02, 2023 11:36 am
by Natter
Hi,

I created xBrowse with FOOTER clause. And he pointed out
Code: Select all  Expand view
oBrw:aCols[1]:nFooterType:=AGGR_SUM
 ........................................................
 oBrw:aCols[n]:nFooterType:=AGGR_SUM

Then, using oBrw:MakeTotals, it is possible to perform summation according to these columns.

Is it possible to perform summation not on all lines, but on some condition ?

Re: Summation by condition

PostPosted: Fri Jun 02, 2023 11:55 am
by Marc Venken
Here some samples

oBrw:Age:bSumCondition := { |v,o| o:Value % 2 == 1 }, ;
oBrw:State:nFooterType := AGGR_COUNT, ;
oBrw:State:bSumCondition := { |v,o| "A" $ o:Value }, ;
oBrw:Salary:nFooterType := AGGR_SUM, ;
oBrw:Salary:bSumCondition := { || .NOT. FIELD->MARRIED }, ;

//oBrw[6]:sel:bSumCondition := { || ( oBrw:cAlias )->selected }

oBrw:chm_send:nFooterType := AGGR_COUNT
oBrw:chm_send:bSumCondition := { || if ( ( oBrw:cAlias )->chm_send > 0, .t., .f. ) }
oBrw:chm_BOU:nFooterType := AGGR_COUNT
oBrw:chm_BOU:bSumCondition := { || if ( ( oBrw:cAlias )->chm_bounce > 0, .t., .f. ) }

:aCols[3]:bSumCondition := { |v,o| (cFileName)->(DELETED()) } // You defined Alias

oBrw:totaal:nFooterType := AGGR_SUM
oBrw:totaal:bSumCondition := { || ( oBrw:cAlias )->totaal }

Re: Summation by condition

PostPosted: Fri Jun 02, 2023 11:58 am
by Natter
Thanks, I get it!