SUM with parameter

edited 7:50AM in FastReport 4.0
Hello.


What can i do to sum with parameter ?

Want sum field "Wart".
If other field "Group"<6 then i need sum "Wart" , but if "Group">=6 i need sum (-1*"Wart").
I puted code to event onbeforeprint:

var
war:Extended;
begin
war:=0;
if (<frxD1."Group"> <6) then war:=SUM(<frxD1."Wart">,MasterData1)
else war:=SUM(-1*<frxD1."Wart">,MasterData1);
TfrxMemoView(Sender).Text:=Format('%2.2n',[war]);
end;

but it doesnt work.

Comments

  • gpigpi
    edited 7:50AM
    Use in TfrxMemoView
    [SUM(IIF(<frxD1."Group"> < 6, <frxD1."Wart">, (-1) * <frxD1."Wart">), MasterData1)]
  • edited 7:50AM
    gpi wrote: »
    Use in TfrxMemoView
    [SUM(IIF(<frxD1."Group"> < 6, <frxD1."Wart">, (-1) * <frxD1."Wart">), MasterData1)]


    Thank you.
    Used preview this metod , but why didnt work in event obp ?
  • edited 7:50AM
    1. Did you put TfrxView with that code (obp event) on a summary band, I mean GroupFooter or similar?

    2. The construction
    if (<frxD1."Group"> <6)  
      then war := SUM(<frxD1."Wart">,MasterData1)
      else war := SUM(-1*<frxD1."Wart">,MasterData1); 
    
    seems to me as it can not get real value of SUM().
    Pay attention to what Gpi showed: the whole expression SUM(...) is included in square brackets.

    Mick

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.