Joined: 03 Jul 2008
Location: United States
Online Status: Offline
Posts: 3
Topic: filter keywords Posted: 08 Aug 2008 at 6:33am
I am trying to write a report that pulls out keywords from a field that contains a paragraph. What I need is, if the field contains any of the keywords to only display the contents of the field not just the keywords.
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 09 Aug 2008 at 4:20pm
If you know the keywords in advance, you could use multiple tests to check for each keyword and return the whole field if any of them are true. Something like this:
if (InStr({table.field}, "key1")>0) OR (InStr({table.field}, "key2")>0) OR (InStr({table.field}, "key3")>0) then
{table.field}
ELSE
"";
In my Encyclopedia book, chapters 5,6, 7 are dedicated to showing you how to write formulas and program with Crystal Syntax. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
Joined: 03 Jul 2008
Location: United States
Online Status: Offline
Posts: 3
Posted: 18 Aug 2008 at 2:11pm
Ok, I tried this formula but it still didn't give me what I want. It just gave me a blank field. This is what I have:
if (InStr({Observations.Observation}, "Insects")>0) OR (InStr({Observations.Observation}, "Ants")>0) OR (InStr({Observations.Observation}, "Beetles")>0) OR (InStr({Observations.Observation}, "Stored Pests")>0) then {Observations.Observation} ELSE "";
After creating this formula, where would I put it?
Joined: 03 Jul 2008
Location: United States
Online Status: Offline
Posts: 3
Posted: 22 Aug 2008 at 12:57pm
Nevermind, I got it figured out. The actual formula I needed was the Instr(string1,string2,case). The original was looking for the exact word including case so I wasn't able to find any records that matched. I also figured that I could use the selection expert to exclude on the Else answer which I had changed to 2 once the formula was completed. Thanks for putting in the right direction.
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