Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: falsePart not returned on IIF Statement Post Reply Post New Topic
Author Message
LindaOSU
Newbie
Newbie
Avatar

Joined: 06 Dec 2010
Location: United States
Online Status: Offline
Posts: 9
Quote LindaOSU Replybullet Topic: falsePart not returned on IIF Statement
     Posted: 06 Dec 2010 at 3:08pm
Some of our body measurement records are metric some are not.  I am trying to use an IIF statement to decide if the weight is "M" or "U" (I suppose as in Metric and United States?).  Anyway, this determines how the answer is formated.  "M"records would be 56.8 kg, whereas, "U" records would be 56 lb 8 oz.  I can't get the falsePart of the formula to return a value.  Here is what I started:
 
IIF ({table.unit} = "U",
{table.weight_lb_K} & " lb " & {table.weight_oz_g} & " oz",
{table.weight_lb_K} & "." & {table.weight_oz_g} & " kg")
 
Ideas?  I have the same issue with the height measurements.
 
Thanks!
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 07 Dec 2010 at 3:13am
By "can't return a value" do you just get an empty line?

Have you verified that the current False statement returns data (perhaps by switching the two)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Dec 2010 at 4:21am
if unit <> "U" is it NULL?
If you are not handling NULLs as default values it will not return any FALSE part as the evaluation will stop when it hits a NULL
IP IP Logged
LindaOSU
Newbie
Newbie
Avatar

Joined: 06 Dec 2010
Location: United States
Online Status: Offline
Posts: 9
Quote LindaOSU Replybullet Posted: 07 Dec 2010 at 7:16am

Thanks to Keikoku & DBlank for responding. 

Upon further investigation, I found:

Whatever is in the partTrue of the statement is how the data is formatted.  I noticed that if

IIF ({table.unit} = "U",
{table.weight_lb_K} & " lb " & {table.weight_oz_g} & " oz",
{table.weight_lb_K} & "." & {table.weight_oz_g} & " kg")

is used, all data are formatted as lb oz even though they have "M" in the Unit field. 


IIF ({table.unit} = "U", {table.weight_lb_K} & "." & {table.weight_oz_g} & " kg",
{table.weight_lb_K} & " lb " & {table.weight_oz_g} & " oz")

is used, all data are formatted as X.X kg no matter if "U" or "M" is in the Unit field.

And any records that have a blank (Null?) return no data.  Some records have no date for any of these fields, other
records have blanks in the {table.weight_oz_g} field, presumably since the weight was even lbs or K. 
How can I get it to put a "0" in the {table.weight_oz_g} field?

Thank you
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Dec 2010 at 7:59am
try:
if isnull({table.unit}) or {table.unit}="" then "0"
else
if ({table.unit} = "U" then {table.weight_lb_K} & " lb " & {table.weight_oz_g} & " oz" else
if ({table.unit} = "M" then {table.weight_lb_K} & "." & {table.weight_oz_g} & " kg" else "0"
 


Edited by DBlank - 07 Dec 2010 at 8:48am
IP IP Logged
LindaOSU
Newbie
Newbie
Avatar

Joined: 06 Dec 2010
Location: United States
Online Status: Offline
Posts: 9
Quote LindaOSU Replybullet Posted: 07 Dec 2010 at 8:46am
Thank you.  Your code got me going in the right direction and now it works.  Thanks so much!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum