How does the IIF function work?

Stimulsoft Reports.Flex discussion
Locked
esfisher
Posts: 9
Joined: Wed Dec 15, 2010 3:37 pm
Location: Aurora, IL

How does the IIF function work?

Post by esfisher »

I'm evaluating your software for use with our flex-based software. I'm trying to create a report that lists individuals and their phone numbers. Some individuals do not have phone numbers, so I want to check for 'null' values and output an empty string if that is the case.

If I do nothing, using {registrant_data.phone_number}, then the report outputs 'null' in the phone column for those individuals without phone numbers and the correct phone number for those who do have phone numbers.

If I use the expression

Code: Select all

{(registrant_data.phone_number == null) ? '' : registrant_data.phone_number}
or

Code: Select all

{IFF((registrant_data.phone_number == null),'',registrant_data.phone_number)}
then I get nothing in the output, even for those registrants with phone numbers.

I also have another situation where I need to check registrants against a guardian name. If they are the same, meaning they have no guardian, then it should display nothing. If they are different, meaning they have a guardian, it should display the guardian name. However, the following expression does not work:

Code: Select all

{IFF((registrant_data.primary_name == registrant_data.participant_name),'',registrant_data.primary_name)}
My question is, what do I need to do to get the IIF function to compare and output the correct values?

Also, I am sending the report data via XML
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

How does the IIF function work?

Post by Ivan »

Hello,

Please try to use the following expressions:

Code: Select all

{(registrant_data.phone_number == null) ? "" : registrant_data.phone_number}
{IIF((registrant_data.phone_number == null),"",registrant_data.phone_number)}
{IIF((registrant_data.primary_name == registrant_data.participant_name),"",registrant_data.primary_name)}
Thank you.
esfisher
Posts: 9
Joined: Wed Dec 15, 2010 3:37 pm
Location: Aurora, IL

How does the IIF function work?

Post by esfisher »

Thank you. That fixed it.
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

How does the IIF function work?

Post by Andrew »

Ok!

Have a great day!

Thank you.
PRabbat
Posts: 2
Joined: Thu Dec 08, 2011 10:15 am
Location: GA

How does the IIF function work?

Post by PRabbat »

Hello,

I am having a similar issue, however, I am attempting to evaluate a boolean instead of a string.

Using the previous example, let's say I have a boolean labeled registrant_data.has_phone_number. First, I need to check if the expression is null. If it's not null, I need to check the value of the has_phone_number boolean. If it is true, I want to display the text "Has Phone Number" in a grid. If the value is false, I want to display "Does Not Have Phone Number".

The expression:

Code: Select all

{(registrant_data.has_phone_number == null) ? "" : registrant_data.has_phone_number}
{IIF((registrant_data.has_phone_number == null),"",registrant_data.has_phone_number)}
{IIF((registrant_data.has_phone_number),"Has Phone Number", "Does Not Have Phone Number")}
Does not work because the IFF expects a string instead of a boolean. Is there a way around this?

Thanks,
Paul
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

How does the IIF function work?

Post by HighAley »

Hello, Paul.
PRabbat wrote:I am having a similar issue, however, I am attempting to evaluate a boolean instead of a string.

Using the previous example, let's say I have a boolean labeled registrant_data.has_phone_number. First, I need to check if the expression is null. If it's not null, I need to check the value of the has_phone_number boolean. If it is true, I want to display the text "Has Phone Number" in a grid. If the value is false, I want to display "Does Not Have Phone Number".

The expression:

Code: Select all

{(registrant_data.has_phone_number == null) ? "" : registrant_data.has_phone_number}
{IIF((registrant_data.has_phone_number == null),"",registrant_data.has_phone_number)}
{IIF((registrant_data.has_phone_number),"Has Phone Number", "Does Not Have Phone Number")}
Does not work because the IFF expects a string instead of a boolean. Is there a way around this?
Which expression of three ones do you use?

Thank you.
PRabbat
Posts: 2
Joined: Thu Dec 08, 2011 10:15 am
Location: GA

How does the IIF function work?

Post by PRabbat »

I am using the expression:

Code: Select all

{IIF(((registrant_data.has_phone_number == null) || !(registrant_data.has_phone_number)  ),"","The User Has a Phone Number")}
As stated before, has_phone_number is a boolean.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How does the IIF function work?

Post by Alex K. »

Hello,

We check this expression and it is work correctly.
Can you please send us your report with test data for analysis.

Thank you.
smith512
Posts: 1
Joined: Mon Dec 02, 2013 12:34 pm

Re: How does the IIF function work?

Post by smith512 »

Hiii
can any one help me out how to use multiple if else condition using IIF with example

im using this expression {(registrant_data.has_phone_number == null) ? "" : registrant_data.has_phone_number}

and i want to execute if elseif else

im getting syntax error or the output is blank.

thanks in advance
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How does the IIF function work?

Post by HighAley »

Hello.

Please, try to remove Braces {} from your expression.

Thank you.
Locked