Forum > LazReport
Is possible sum if condition
(1/1)
eldonfsr:
Hi i need a report witch column input and outs so create a report i can get print information separated but i don't know how sum that band total or group.
can possible use formula loke this
if( [DM.SQLQTrans."type"]='add' or [DM.SQLQTrans."type"]='asin') then begin sum([DM.SQLQTrans."quntity"]
end else begin
[DM.SQLQTrans."quntity"]=0;
end;
eldonfsr:
Ok after play i made some changes
you can see on image or report how i put de data intotals and outtotals
code some events on report events.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFormTransPeri.frReportPartTransEndBand(Band: TfrBand);begin// if(Band.Name = 'DetailData1') Then begin if(Band.Name = 'DetailFooter1') Then begin intotals:=0; outtotals:=0; end; end; procedure TFormTransPeri.frReportPartTransGetValue(const ParName: String; var ParValue: Variant);begin if( ParName='datestart') then begin ParValue:= DEStart.Date; end; if( ParName='dateend') then begin ParValue:= DEEnd.Date; end; if( ParName='incomes') then begin if( (DM.SQLQTrans.FieldByName('Type').AsString = 'add') or (DM.SQLQTrans.FieldByName('Type').AsString = 'asin') ) then begin ParValue:= DM.SQLQTrans.FieldByName('quantity').AsString ; Intotals:=Intotals+DM.SQLQTrans.FieldByName('quantity').AsInteger; end else begin ParValue:='' ; end; end; if( ParName='outgoing') then begin if( (DM.SQLQTrans.FieldByName('Type').AsString = 'sub') or (DM.SQLQTrans.FieldByName('Type').AsString = 'asout') ) then begin ParValue:= DM.SQLQTrans.FieldByName('quantity').AsString ; Outtotals:=Outtotals+DM.SQLQTrans.FieldByName('quantity').AsInteger; end else begin ParValue:='' ; end; end; if( ParName='intotals') then begin ParValue:=intTostr(intotals) ;// intotals:=0; end; if( ParName='outtotals') then begin ParValue:=intTostr(outtotals) ;// outtotals:=0; end; end;
Navigation
[0] Message Index