cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Nested if else statement crystal report

Former Member
0 Likes
1,944

Hi,

I'm quite new to Crystal Reports and I'm stuck, hoping someone here can help me.

I have a report that where I want to print the address to where we shipped our orders. I have four different fields where there can be information about shipping address.

ordlevadr2 (first prio) - if there is data in this field always use that one

ftgpostadr5 (second prio) - if ordlevadr2 is empty look if there is any value here, use this one

ftgpostadr2 (third prio) - if ordlevard2 and ftgpostadr5 is empty and there is a value in this field, use this one

ftgpostadr4 (last prio) - if ordlevadr2, ftgpostadr5 and ftgpostadr2 is empty use this one

if all of the fields are empty set text 'none'

I have tried with below code, but I can't get it right

if ISNULL({q_import_tableu;1.ordlevadr2}) then ( if ISNULL({q_import_tableu;1.ftgpostadr2}) then {q_import_tableu;1.ftgpostadr5} else if ISNULL({q_import_tableu;1.ftgpostadr5}) then {q_import_tableu;1.ftgpostadr2} else if ISNULL({q_import_tableu;1.ftgpostadr4}) then {q_import_tableu;1.ftgpostadr5} else 'none'; ) else {q_import_tableu;1.ordlevadr2}+' '+{q_import_tableu;1.ordlevadr3}

View Entire Topic
vitaly_izmaylov
Product and Topic Expert
Product and Topic Expert
0 Likes

Try:

if not (ISNULL({q_import_tableu;1.ordlevadr2}) or ({q_import_tableu;1.ordlevadr2}="")

then

{q_import_tableu;1.ordlevadr2}

else

if not (ISNULL({q_import_tableu;1.ftgpostadr5}) or ({q_import_tableu;1.ftgpostadr5}="")

then

{q_import_tableu;1.ftgpostadr5}

else

if not (ISNULL({q_import_tableu;1.ftgpostadr2}) or ({q_import_tableu;1.ftgpostadr2}="")

then

q_import_tableu;1.ftgpostadr2}

else

if not (ISNULL({q_import_tableu;1.ftgpostadr4}) or ({q_import_tableu;1.ftgpostadr4}="")

then

{q_import_tableu;1.ftgpostadr4}

else "none"

Former Member
0 Likes

Thank you very much!!

It's working and I get the correct addresses that I want in the field 🙂