Strange IIF behavior

Stimulsoft Reports.NET discussion
Post Reply
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Strange IIF behavior

Post by Fabio Pagano »

Using version of 5 January 2009.

My sample project has this IIF in the group totals, to print "is zero" when the sum is zero and "" when the sum is not zero:

Code: Select all

{IIF(Sum(MyTable.Value)==0,"is zero","")}
This is the designer screenshot, in red square is the field with the problem:

Image

It should give this output:

Image

But it gives this:

Image

If in the field containing the IIF function (the field is called "Testo2" in my sample project) i set "CanShrink" i obtain this:

Image

If, in the IIF, i change the string returned for the false condition to something > "" (eg. "is not zero"):

Code: Select all

{IIF(Sum(MyTable.Value)==0,"is zero","is not zero")}
everything works as expected (with the new IIF), with "CanShrink" or without:

Image

but, as i told initially, i want a blank string when the sum is != 0.

Note: if i put the field containing the IIF (called "Testo2") in the group header, it works as expected, except when i set "CanShrink": in this case, the field is never printed.

It seems to be a problem when the IIF contains a "" as result and/or when the IIF is in the group footer (and something strange happens in "CanShrink" too).

You can download IIF.zip containing the sample project and report from:

http://www.aziwin.it/public/files/IIF.zip

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Strange IIF behavior

Post by Edward »

Hi Fabio,

Thank you very much for the test application!

Please change the condition as follows:

{IIF(Totals.Sum(IntestazioneGruppo1,MyTable.Value)==0,"is zero","")}

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Strange IIF behavior

Post by Fabio Pagano »

It works, thank you.

But now i have another problem.

In this text:

Code: Select all

{Sum(IntestazioneGruppo2,IIF(MyTable.ValueType=="Do not bill",MyTable.Value,0))}
i cannot put the "Totals" word (don't know if it's important):

Code: Select all

{Totals.Sum(IntestazioneGruppo2,IIF(MyTable.ValueType=="Do not bill",MyTable.Value,0))}
because it gives me an error.

Another problem is that i need to sum only if a field has a certain value (eg. "Do not bill") and in another field (at the left) must appear "is zero" if total is zero and "" if the total is != zero.

Now i have an output like this:

Image

Note that the totals (the rigthmost column) are always ok, but the string at the left (that tells if a total is zero or not) is ok in the header but is wrong in the footer.

The text of the field at the left of the totals in the group footer is:

Code: Select all

{IIF(Sum(IntestazioneGruppo2,IIF(MyTable.ValueType=="Do not bill",MyTable.Value,0))==0,"","is not zero (group footer)")}
Again, note that in all these formulas i cannot use "Totals.Sum" because it gives error, i can only use "Sum".

The sample project is here:

http://www.aziwin.it/public/files/IIF_And_Totals.zip

If you need some other information (i've tried to explain the problem the best i can) please ask me.

Thank you.
Post Reply