Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: filter keywords Post Reply Post New Topic
Author Message
paddockm
Newbie
Newbie


Joined: 03 Jul 2008
Location: United States
Online Status: Offline
Posts: 3
Quote paddockm Replybullet 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.
 
Does anyone have an idea on how to do this?
 
Thanks for your help.


Edited by paddockm - 08 Aug 2008 at 6:34am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
paddockm
Newbie
Newbie


Joined: 03 Jul 2008
Location: United States
Online Status: Offline
Posts: 3
Quote paddockm Replybullet 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?
 
Thanks,
 
Marty
IP IP Logged
paddockm
Newbie
Newbie


Joined: 03 Jul 2008
Location: United States
Online Status: Offline
Posts: 3
Quote paddockm Replybullet 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.
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