I have a user trying to create a define field in InfoAssist to this effect: IF FIELDA LIKE '%' THEN FIELDB ELSE MISSING.
FIELDA has values like "5%" and "10%" and "$5000". InfoAssist isn't having any of this. How do we make this work?
Thanks!This message has been edited. Last edited by: DWaybright,
WebFOCUS 8.2.03 (production), 8.2.06 (testing) AppStudio, InfoAssist Windows, All Outputs
February 14, 2020, 12:34 PM
FP Mod Chuck
Deb
With 8.2.06 I had no luck with LIKE but CONTAINS works just fine in a WHERE statement, but if I replicate your DEFINE I have the same issue as you neither LIKE or CONTAINS works. Better open a case with techsupport...This message has been edited. Last edited by: FP Mod Chuck,
Thank you for using Focal Point!
Chuck Wolff - Focal Point Moderator WebFOCUS 7x and 8x, Windows, Linux All output Formats
February 14, 2020, 02:43 PM
Hallway
quote:
IF FIELDA LIKE '%' THEN FIELDB ELSE MISSING.
This answer assumes the following: 1. FIELDA is an ALPHA field, because LIKE only works on text strings 2. That you are trying to get the ALPHA values that have the percent sign in it.
The percent sign in a LIKE statement is a wildcard. So the statement above is basically saying if the field has anything in it, then return the field. Also if you want MISSING values, you need to set MISSING=ON.
So to get fields with the percent sign, you need to escape the percent sign. Something like this
DEFINE FILE masterFileName
NEWFIELDNAME/A50V MISSING ON = IF FIELDA LIKE '%~%%' ESCAPE '~' THEN FIELDB ELSE MISSING.
END DEFINE
Yes, FIELDA is an alpha field. Sorry I didn't clarify that.
quote:
IF FIELDA LIKE '%~%%' ESCAPE '~' THEN FIELDB ELSE MISSING.
I get an error when I try that. InfoAssist doesn't seem to like ESCAPE. I tried using other characters in place of ~ and got the same error. :/
WebFOCUS 8.2.03 (production), 8.2.06 (testing) AppStudio, InfoAssist Windows, All Outputs
February 14, 2020, 03:41 PM
Hallway
quote:
Originally posted by DWaybright: I get an error when I try that. InfoAssist doesn't seem to like ESCAPE. I tried using other characters in place of ~ and got the same error. :/
*SIGH* Yeah, sorry. I just noticed that. Once again IA saying perfectly valid code is invalid.
I'm trying one other thing of using a REGEX to see if there is a percent sign in the text. I'll post the answer if it works.
Hallway
Prod: 8202M1
Test: 8202M4
Repository:
OS:
Outputs:
February 14, 2020, 03:53 PM
Hallway
The REGEX seems to work for me:
IF REGEX(FIELDA, '[%]') THEN FIELDB ELSE MISSING;
I built this code in IA and it seemed to work:
DEFINE FILE ibisamp/car
Margin/D12.2%=(CAR.BODY.RETAIL_COST / CAR.BODY.DEALER_COST -1)*100;
FIELDA/A25=IF CAR.BODY.SEATS EQ 5 THEN TRIM_(BOTH, ' ', FTOA( CAR.BODY.SALES, '(D12M)', 'A25V')) ELSE TRIM_(BOTH, ' ',FTOA( Margin ,'(D12.2%)', 'A15'));
FIELDB/D12M=CAR.BODY.SALES ;
FIELDC/D12M MISSING ON=IF REGEX(FIELDA, '[%]') THEN FIELDB ELSE MISSING;
END
ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
SET SQUEEZE=ON
-DEFAULTH &WF_HTMLENCODE=ON;
SET HTMLENCODE=&WF_HTMLENCODE
SET HTMLCSS=ON
-DEFAULTH &WF_EMPTYREPORT=ON;
SET EMPTYREPORT=&WF_EMPTYREPORT
-DEFAULTH &WF_SUMMARY='Summary';
-DEFAULTH &WF_TITLE='WebFOCUS Report';
TABLE FILE ibisamp/car
SUM FIELDA
FIELDB
FIELDC
BY CAR.ORIGIN.COUNTRY
BY CAR.COMP.CAR
BY CAR.CARREC.MODEL
BY CAR.BODY.SEATS
ON TABLE PCHOLD FORMAT HTML
ON TABLE NOTOTAL
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/endeflt.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, SUMMARY=&WF_SUMMARY.QUOTEDSTRING, $
ENDSTYLE
END
-RUN