Variables in {IIF(,,)} Statments.

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

Variables in {IIF(,,)} Statments.

Post by David334 »

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: 6243
Joined: Tue Mar 20, 2018 5:34 am

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

Post by Lech Kulikowski »

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: 29
Joined: Tue Jul 16, 2019 6:45 pm

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

Post by David334 »

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

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

Post by Andrew »

Great!

Thank you for the info!
Post Reply