Page 1 of 1

Conditional formatting based on sum() totals

Posted: 29 Aug 2012, 14:37
by mpfj
I'm trying to hide / show a "Discount" header text box when a sales total discount is zero / non-zero.

I have a text box showing "Discount" and the conditional expression:-

if sum(Rounddp(SOP_ITEM.FOREIGN_FULL_NET_AMOUNT, 2) - Rounddp(SOP_ITEM.FOREIGN_NET_AMOUNT, 2) + Rounddp(SALES_ORDER.NET_VALUE_DISCOUNT_NET, 2)) = 0 then
begin
Visible := False;
end

This is based on the "Total_Discount" expression in the footer of the default layout.

Here's the problem ... this all seems to work fine provided the *first* item (and/or any other item) in the sale has a discount value.

If I only apply a discount to the (say) final item, my conditional expression always hides the header.

Am I doing something wrong ?

Thanks for any help you can provide.

Re: Conditional formatting based on sum() totals

Posted: 31 Aug 2012, 09:58
by brucedenney
You say "header text box" not fully sure what you mean.

The header is printed before the items, so the sum of the items is the sum of the first item at that point. Until all the items on the invoice have been printed "we" can not know the total of the items and if there is a discount amount. This is why totals have to be in footers.

Assuming you do not mean a header section, but are referring to a Discount header in a footer section then it should work, however you could simplify it to

if Total_Discount = 0 then
begin
Visible := False;
end

If you still have problems, please attach the report/layout to your post