Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Designating Analysis Codes per Column Post Reply Post New Topic
Author Message
AmyTheJoy
Newbie
Newbie
Avatar

Joined: 03 Sep 2013
Online Status: Offline
Posts: 6
Quote AmyTheJoy Replybullet Topic: Designating Analysis Codes per Column
    Posted: 03 Sep 2013 at 12:16pm
Hello.

I am a chemist and we give analytical results for a wide variety of elements. I need to be able to tell the results of certain elements to appear in certain columns. I have tried writing If-Then statements that say:

      If {FLATDATA.ANAM} = "Arsenic" then {FLATDATA.ACOM}
      else ""

or
      If {FLATDATA.ACOD} = "FA-WEIGHT-FACTOR" then
      {FLATDATA.ACOM} else ""

But... it doesn't seem to be working. The results aren't showing up at all.
IP IP Logged
iSing
Newbie
Newbie


Joined: 12 Mar 2013
Online Status: Offline
Posts: 22
Quote iSing Replybullet Posted: 04 Sep 2013 at 5:40pm
Hi AmyTheJoy
 
There's nothing wrong with your formula, but it's assuming a few things. In your first example,
1. {FLATDATA.ANAM} always contains data.  If it doesn't you need to allow for null fields.
2.  Arsenic is exactly this - it is in proper case (eg the A is capitalised & the rest is lowercase) and there are no spaces around it.  Thus if the actual data of {FLATDATA.ANAM} was "ARSENIC  " it wouldn't find it (as it's in capitals & it has two spaces at the end).
 
I'm assuming that {FLATDATA.ANAM} is a free text field & not tied to a code list?
 
If {FLATDATA.ANAM} must always contain a result then try:
if trim(lowercase({FLATDATA.ANAM}) = "arsenic" then {FLATDATA.ACOM} else ""
 
If it can be null, or contain no characters, try:
If isnull({FLATADATA.ANAM} or totext({FLATDATA}="" then "" else
if trim(lowercase({FLATDATA.ANAM}) = "arsenic" then {FLATDATA.ACOM} else ""
 
What this is doing:
the use of "isnull" is checking to see if there is no entry in the field.
the use of "totext" is checking to see if there is an entry of zero characters in this field.
the use of "trim" is removing any spaces around your field (eg it will allow for spaces before or after the word arsenic.
The use of "lowercase" is forcing the contents of your field to be lowercase, so it is comparing arsenic with arsenic, not ARSENIC or anything else.
 
You can always test this by replacing the "" with different words "bob", "fred", "jane" to see that the combination is working.
 
If you are looking at a code list, then I'd check the raw data of your code list, in case someone has replaced "Arsenic" with other versions (eg "arsenic", "Arsenic  ", "  Arsenic  " etc, etc.
 
Hope this helps
 
 
IP IP Logged
AmyTheJoy
Newbie
Newbie
Avatar

Joined: 03 Sep 2013
Online Status: Offline
Posts: 6
Quote AmyTheJoy Replybullet Posted: 10 Sep 2013 at 12:16pm
Thank you for your answer. Hugely. I've had it open on my computer for two days while I try to fix all kinds of things. It does work now!!

Thank you very much for your help. I'm learning a bit about syntax, and when it works I feel ALL POWERFUL!! :) Well. Almost. Cheers!
IP IP Logged
iSing
Newbie
Newbie


Joined: 12 Mar 2013
Online Status: Offline
Posts: 22
Quote iSing Replybullet Posted: 10 Sep 2013 at 2:45pm
Hi AmyTheJoy
 
We've all been at the point of thinking "this must be possible" but frustrated by lack of technical knowledge.  I have soooo been there.
 
Glad I could shine a light on your Crystal knowedge path.

 

IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.012 seconds.