ERROR SUM AND IFF

MAICONMAICON BRAZIL
edited 9:48AM in FastReport 4.0
HI, I'M TRYING USE THIS CODE:
[IFF([DBLAN."IN_M"] = 'A', [SUM(<DBLAN."VL_M">,DetailData1)], '0')]

BUT RETURNED AN ERROR.
Memo1: Erro na express??o 'IFF([DBLAN."IN_M"] = 'A', [SUM(<DBLAN."VL_M">,DetailData1)], '0')': Identifier expected

WHAT AM I DOING WRONG?

SORRY FOR MY BAD ENGLISH;

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 9:48AM
    [IFF([DBLAN."IN_M"] = 'A', [SUM(<DBLAN."VL_M">,DetailData1)], '0')]
    too many [] in the expression
    use the builtin expression builder to build your expression
    try this
    [iif((<DBLAN."IN_M">= 'A"),(SUM(<DBLAN."VL_M">,DetailData1)),'0')]
    or use the builtin expression builder to build your expression it will set the correct braces for you


  • edited September 2013
    gordk wrote: »
    [IFF([DBLAN."IN_M"] = 'A', [SUM(<DBLAN."VL_M">,DetailData1)], '0')]
    too many [] in the expression
    use the builtin expression builder to build your expression
    try this
    [iif((<DBLAN."IN_M">= 'A"),(SUM(<DBLAN."VL_M">,DetailData1)),'0')]
    or use the builtin expression builder to build your expression it will set the correct braces for you
    This should work.

    Simply remember, there must only ever be one set of [] brackets in an expression.
  • MAICONMAICON BRAZIL
    edited 9:48AM
    Right! The error no longer occurs.
    But the calculation is not correct.

    Eg: Master data
    Order N??: 100
    Detail data
    Name Product Qty Price State
    Product x 1 10,00 A
    Product y 1 20,00 C
    Product z 1 8,00 A
    Footer
    Grand Total: 38,00

    The sum does not match.
    The total should be: 18,00

    Thanks for the help!
  • gordkgordk St.Catherines On. Canada.
    edited 9:48AM
    in which band is the the memo with the expression located.
  • MAICONMAICON BRAZIL
    edited 9:48AM
    gordk wrote: »
    in which band is the the memo with the expression located.

    not sure I understand the question, but,
    the command is in a memo in footer
  • gordkgordk St.Catherines On. Canada.
    edited 9:48AM
    the sum function does not differentiate values in that way.
    what you need to do is to create a variable initialize it to zero before the detailbands start to print
    either in a detailheader or the masterdataband.
    in the obp event of detailband add the values according to the test field value

    if <DBLAN."IN_M" = 'A" myvarname :=myvarname + <datasetname."valuefieldname">;

    use the variable in the memo in the footer.
  • MAICONMAICON BRAZIL
    edited 9:48AM
    right, it worked!
    thanks for your help and attention!
    >

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.