"Sum doesn't exist in the current context" in nested IIF

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

"Sum doesn't exist in the current context" in nested IIF

Post by Fabio Pagano »

In a text field i have the following expression (nested "IIF"):

Code: Select all

{IIF(Sum(Movimenti.Saldo)>=0,"Utile del periodo",IIF(Sum(Movimenti.Saldo)<0,"Perdita del periodo",""))}
When i run the report, i receive the following error:

"Sum name doesn't exist in the current context".

If I replace the second "Sum" with another condition (say "1<0"), no error appears

Code: Select all

{IIF(Sum(Movimenti.Saldo)>=0,"Utile del periodo",IIF(1<0,"Perdita del periodo",""))}
It seems that the problem is in the sum in a nested IIF.

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: "Sum doesn't exist in the current context" in nested IIF

Post by Alex K. »

Hello,

Can you please send us a sample report with test data for analysis.

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

Re: "Sum doesn't exist in the current context" in nested IIF

Post by Fabio Pagano »

Attached is a sample report and data.

The error is in the field "Text2" in the group footer.

Thank you.
Attachments
data.xml
(785 Bytes) Downloaded 305 times
Sum_Doesnt_exist.mrt
(11.86 KiB) Downloaded 517 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: "Sum doesn't exist in the current context" in nested IIF

Post by HighAley »

Hello.

We have reproduced your issue. We need some time to give you an answer.
For a while you could set the Calculation Mode property of the report to Interpretation.

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: "Sum doesn't exist in the current context" in nested IIF

Post by HighAley »

Hello.

Please, to use ?: operator instead of the IIF() function. Your expression will be next:

Code: Select all

{IIF(Sum(Data.IDCustomer)>=0,"Utile del periodo", Sum(Data.IDCustomer)<0 ? "Perdita del periodo" : "")}
Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Re: "Sum doesn't exist in the current context" in nested IIF

Post by Fabio Pagano »

Good evening.

Now i'm using version 2015.2.0.0 and the following sample statement (based on what you've suggested):

Code: Select all

{IIF(Sum(0)>=0,"Utile del periodo", Sum(0)<0 ? "Perdita del periodo" : "")}
gives the following error:

'There is no matching overloaded method for "IIF(Object,Int32,Object)'

when i press the button "Check" in the editor.

Anyway, the statement works fine in report, only the "Check" button in the editor gives the above error (so it's not a problem at the moment).

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: "Sum doesn't exist in the current context" in nested IIF

Post by HighAley »

Hello. Fabio.

We have reproduced the issue.
We will let you know about results soon.

Thank you.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: "Sum doesn't exist in the current context" in nested IIF

Post by Ivan »

Hello,

The problem is solved.
The patch will be available in the next prerelease build.

Thank you.
Post Reply