Summation by condition

Summation by condition

Postby Natter » Fri Jun 02, 2023 11:36 am

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 ?
Natter
 
Posts: 1203
Joined: Mon May 14, 2007 9:49 am

Re: Summation by condition

Postby Marc Venken » Fri Jun 02, 2023 11:55 am

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 }
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Summation by condition

Postby Natter » Fri Jun 02, 2023 11:58 am

Thanks, I get it!
Natter
 
Posts: 1203
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests