Variables in {IIF(,,)} Statments.

Stimulsoft Reports.Wpf discussion
Post Reply
David334
Posts: 17
Joined: Tue Jul 16, 2019 6:45 pm

Variables in {IIF(,,)} Statments.

Post by David334 » Tue Dec 03, 2019 7:36 pm

Hi, I am having an issue with using variables.
I have a basic statement like this:
{IIF(column=='N',Variable=Variable+1,Variable+1)}

I feel this may be the incorrect way to use a variable because it seem the IF statement executes both sections if the statement is false.
For example, if column equals 'N', the result is a increasing variable by 1, But if "column" is not equal to 'N', the statement executes both sections of the IIF clause, first incrementing itself my one, and then adding 1 again for the displayed output.

I was hoping it would just skip over the first section, but it seem to execute both parts of IIF statement no matter what.
Lech Kulikowski
Posts: 2688
Joined: Tue Mar 20, 2018 5:34 am

Re: Variables in {IIF(,,)} Statments.

Post by Lech Kulikowski » Sun Dec 08, 2019 10:12 pm

Hello,

Yes, IIF() function in any case, execute both statements.

In your case, you can use the following expression:
{(column == 'N' ? Variable=Variable+1 : Variable+1)}

Thank you.
David334
Posts: 17
Joined: Tue Jul 16, 2019 6:45 pm

Re: Variables in {IIF(,,)} Statments.

Post by David334 » Mon Dec 09, 2019 10:01 pm

<t>Thank you, that works.</t>
Andrew
Posts: 3997
Joined: Fri Jun 09, 2006 3:58 am

Re: Variables in {IIF(,,)} Statments.

Post by Andrew » Tue Dec 10, 2019 6:59 am

Great!

Thank you for the info!
Post Reply