Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Specific word in a alpha field
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Specific word in a alpha field
 Login/Join
 
Gold member
posted
Hi

I need to define a field that will look for the word Rush in a comment field and will equal 1 if it does and 0 if it does not

I am not trying to find only the record with Rush in it but just show which record have and which don't

Problem is that comment field can show " Please ship rush ", " this order is rush ", " Rush order " and so on as these comment are not always enter by the same user

This is something I never did before and help would be greatly appreciated

Thank you.

This message has been edited. Last edited by: FP Mod Chuck,


7.6. / Win 7 / Excel
 
Posts: 56 | Location: St-Laurent QC Canada | Registered: February 04, 2009Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Assuming you're running 8.2xx, try the POSITION function and count the ones that have a value not equal to 0.

https://webfocusinfocenter.inf.../source/position.htm


In this example I'm flagging the records that have 'GER' in the field COUNTRY.
  

TABLE FILE CAR
PRINT COUNTRY CAR
COMPUTE GER_IN_COUNTRY/I2=POSITION('GER', COUNTRY); NOPRINT
COMPUTE RECORDS_WITH_GER/I2=IF GER_IN_COUNTRY NE 0 THEN 1 ELSE 0;
END

This message has been edited. Last edited by: BabakNYC,


WebFOCUS 8204, Unix, Windows
 
Posts: 1617 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
And since the case may be important

TABLE FILE CAR
PRINT COUNTRY CAR
COMPUTE GER_IN_COUNTRY/I2=POSITION('GER', UPCASE(10, COUNTRY, 'A10')); NOPRINT
COMPUTE RECORDS_WITH_GER/I2=IF GER_IN_COUNTRY NE 0 THEN 1 ELSE 0;
END


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2105 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Platinum Member
posted Hide Post
There's also "CONTAINS" ...

TABLE FILE CAR
PRINT MODEL
BY COUNTRY
BY CAR
END
-*
TABLE FILE CAR
PRINT MODEL
BY COUNTRY
BY CAR
WHERE MODEL CONTAINS 'AUTO' OR 'III'
END


You would still need to deal with mixed case values.


WebFocus 8.201M, Windows, App Studio
 
Posts: 221 | Location: Lincoln Nebraska | Registered: August 12, 2008Reply With QuoteReport This Post
Virtuoso
posted Hide Post
MartinY has a point. I'd upcase the values before checking.

FYI, there's now a simplified UPPER(fieldname) function that's slightly easier than UPCASE.

  
TABLE FILE CAR
PRINT COUNTRY CAR
COMPUTE GER_IN_COUNTRY/I2=POSITION('GER', UPPER(COUNTRY)); NOPRINT
COMPUTE RECORDS_WITH_GER/I2=IF GER_IN_COUNTRY NE 0 THEN 1 ELSE 0;
END


Regarding CONTAINS, I agree that's another way of approaching the issue. You could also use LIKE. Many ways to get to the same outcome.


WebFOCUS 8204, Unix, Windows
 
Posts: 1617 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
quote:
there's now a simplified UPPER(fieldname) function that's slightly easier than UPCASE

Old habits Smiler


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2105 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
The REGEX function returns 1 or 0 based on match:

This does a case insensitive search for the word "imports".

DEFINE FILE GGPRODS
IMP/I5 = REGEX(VENDOR_NAME,'(?i)\bimports\b');
END
TABLE FILE GGPRODS
PRINT *  IMP
END  


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1096 | Location: Toronto, Ontario | Registered: May 26, 2004Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Specific word in a alpha field

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.