I was wondering if it's possible to display different formats in a single field for a report. I have 1 field in my data that displays all the values we may need for any measure. The format of the field is A50V, I need to display these values in this field as either percent, number or string depending on which measure the value is for. Is this possible??
Here is an example of what the data looks like Measure Name Score Measure 1 50 Measure 2 Very High Measure 3 88
Then here is what I need to the report to look like Measure Name Score Measure 1 50 minutes Measure 2 Very High Measure 3 88%
Any and all advice is appreciated, thanks!!This message has been edited. Last edited by: cldiaz,
WebFOCUS 8204 Windows, All Outputs
December 14, 2017, 01:11 AM
Chaudhary
Yes It is possible, Make conditional compute(varchar) in your table file request ,
Try Something like this, or paste your sample code
TABLE FILE CAR
SUM
COMPUTE SCORE/A28V = IF CAR EQ 'AUDI' THEN (PTOA(SEATS, '(P3)', 'A5V')|'%') ELSE IF CAR EQ 'BMW' THEN (PTOA(SEATS, '(P3)', 'A4V')|'Minutes') ELSE 'Very High'; AS 'Score'
BY CAR.COMP.CAR
WHERE CAR IN ('AUDI' , 'BMW' , 'ALFA ROMEO');
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
ENDSTYLE
END
---------------------
CAR |Score
-----------|-------
ALFA ROMEO |Very High
AUDI |5 %
BMW |29 Minutes
This message has been edited. Last edited by: Chaudhary,
You can DEFINE a format specifier field containing the desired WF display format and use that as your measure's type. This format field has to be absolutely positively specified as nothing else than type A8, or it won't work.
DEFINE FILE CAR
FMT/A8 = DECODE CAR ('AUDI' 'P3%', 'BMW' 'D12.3' ELSE 'D12');
END
TABLE FILE CAR
PRINT SEATS/FMT
BY CAR
BY MODEL
END
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
December 14, 2017, 08:21 AM
MartinY
Or you may also want to take a look at FPRINT function
DEFINE FILE CAR
DCOST /P5 = DEALER_COST;
RCOST /P6CM = RETAIL_COST;
PCT /P6.1% = (RETAIL_COST - DEALER_COST) / RETAIL_COST * 100;
END
TABLE FILE CAR
SUM DEALER_COST
RETAIL_COST
DCOST
RCOST
PCT
COMPUTE MIXFIELD /A10V = IF COUNTRY EQ 'ENGLAND' THEN FPRINT(DCOST, 'P5', 'A10V') ELSE IF COUNTRY EQ 'ITALY' THEN FPRINT(RCOST, 'P6CM', 'A10V') ELSE FPRINT(PCT, 'P6.1%', 'A10V');
BY COUNTRY
BY CAR
WHERE COUNTRY EQ 'ENGLAND' OR 'ITALY' OR 'JAPAN';
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
ENDSTYLE
END
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
December 14, 2017, 12:51 PM
cldiaz
Thanks all, I really appreciate the responses! I ended up using Chaudharys solution and was able to get the data to display as different formats.
WebFOCUS 8204 Windows, All Outputs
December 14, 2017, 03:34 PM
susannah
i use the same thing as wep5622, have used it for years. works like a charm.
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
January 03, 2018, 05:16 PM
cldiaz
Updating to add that I had a second report where I had to display different formats and I used wep5622's solution and it worked beautifully!!