Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If, Then and IsNull Help

Status
Not open for further replies.

Cort

MIS
Apr 16, 2002
154
US
Thanks again for all the help youve given me. I'm trying to get this formula to work but I'm getting an error about a missing then so I'm sure it all messed up:

if isnull({dbo_PHRATE1_CURR.UNIT_YEAR_BUILT}) and if isnull({dbo_PDRATE2_CURR.UNIT_YEAR_BUILT})
then "NA" else if isnull({dbo_PHRATE1_CURR.UNIT_YEAR_BUILT}) then {dbo_PDRATE2_CURR.UNIT_YEAR_BUILT} else {dbo_PHRATE1_CURR.UNIT_YEAR_BUILT}

What I'm trying to do is if {dbo_PHRATE1_CURR.UNIT_YEAR_BUILT} AND {dbo_PDRATE2_CURR.UNIT_YEAR_BUILT} are both null values I want "NA" to print. If they aren't both null then I want to compare {dbo_PHRATE1_CURR.UNIT_YEAR_BUILT} and if that is null print the value in {dbo_PDRATE2_CURR.UNIT_YEAR_BUILT} if it is not null i want the value in {dbo_PHRATE1_CURR.UNIT_YEAR_BUILT} to be returned.

Thanks again for helping me.
 
if (
isnull({dbo_PHRATE1_CURR.UNIT_YEAR_BUILT})
and
isnull({dbo_PDRATE2_CURR.UNIT_YEAR_BUILT})
)
then
"NA"
else
if isnull({dbo_PHRATE1_CURR.UNIT_YEAR_BUILT})
then
{dbo_PDRATE2_CURR.UNIT_YEAR_BUILT}
else
{dbo_PHRATE1_CURR.UNIT_YEAR_BUILT}

Easier to ponder this way for me.

I omitted the second if and wrapped it in parens with the 1st.

-k kai@informeddatadecisions.com
 
Dear Cort,

I believe you have an extra if right on the irst line.

Try this:

if isnull({dbo_PHRATE1_CURR.UNIT_YEAR_BUILT}) and
isnull({dbo_PDRATE2_CURR.UNIT_YEAR_BUILT})
then "NA"
else if isnull({dbo_PHRATE1_CURR.UNIT_YEAR_BUILT})
then {dbo_PDRATE2_CURR.UNIT_YEAR_BUILT}
else {dbo_PHRATE1_CURR.UNIT_YEAR_BUILT}


Hope this is helpful,
ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Dear Cort,

Use SynapseVampire's (we must have posting at the same time as your response wasn't there when I started). He remembered to enclose the entire first expression in parens which is best!

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Thank you very much. That's exactly what I needed. For some reason I had it in my head that if you were using And you had to follow it with another If statement.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top