Print Page | Close Window

Designating Analysis Codes per Column

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19981
Printed Date: 28 Mar 2024 at 8:58am


Topic: Designating Analysis Codes per Column
Posted By: AmyTheJoy
Subject: Designating Analysis Codes per Column
Date 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.



Replies:
Posted By: iSing
Date 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
 
 


Posted By: AmyTheJoy
Date 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!


Posted By: iSing
Date 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.

 




Print Page | Close Window