Focal Point
Suppressing a column with all zero or null values

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1001039422

April 24, 2007, 11:20 AM
Shankar
Suppressing a column with all zero or null values
Hi,
I've a report which has 10 static columns. It displays all the 10 columns at any given time even if 5 columns (out of these 10 columns) have all zero or null values which is an absolute waste.
So I want to make these columns dynamic, i.e. only those columns should be displayed which have at least one non-zero value and those columns should be suppressed which have all zero or null values.
Any suggestions are welcome.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
April 24, 2007, 11:42 AM
Francis Mariani
Here's a suggestion, since you want something dynamic, it will take two passes through the data, one to determine which columns are blank and one for the report.

-SET &ECHO=ALL;

SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA
-RUN

DEFINE FILE CAR
DUMMY1/I6 = 0;
END
-RUN

TABLE FILE CAR
SUM
ACCEL/D15
DUMMY1/D15
ON TABLE HOLD AS H001
END
-RUN

-READ H001 &A_ACCEL.I15. &A_DUMMY1.I15.

-SET &REP_LINE = IF &A_ACCEL GT 0 THEN 'ACCEL' ELSE '';
-SET &REP_LINE = IF &A_DUMMY1 GT 0 THEN 'DUMMY1' ELSE &REP_LINE;

TABLE FILE CAR
PRINT
&REP_LINE
HEADING
"WEBFOCUS REPORT"
ON TABLE SET PAGE NOLEAD
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLESHEET *
BORDER=1, BORDER-COLOR=SILVER,
FONT='ARIAL', SIZE=8, $
END



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 24, 2007, 11:55 AM
FrankDutch
Shankar

Please update your signature so we all know what version you are using.

To answer your question, I would first put the data into a hold file, then test if the values are worth to be displayed by summing the absolute value.
if the absolute value per field is not zero it should be displayed

-SET &ECHO=ALL;
TABLE FILE CAR
SUM SALES RETAIL_COST COMPUTE ZERO=0;
BY COUNTRY
ON TABLE HOLD
END
DEFINE FILE HOLD
DUMMY/A1='';
ASALES/D10=ABS(SALES);
ARETAIL/D10=ABS(RETAIL_COST);
AZERO/D10=ABS(ZERO);
END
TABLE FILE HOLD
SUM  ASALES
 ARETAIL
 AZERO
ON TABLE HOLD AS NPR FORMAT ALPHA
END
-RUN
? HOLD NPR
-READ NPR  &PRSAL.I10. &PRRET.I10. &PRZER.I10.
-TYPE &PRSAL &PRRET &PRZER

-SET &PR1=IF &PRSAL EQ 0 THEN 'NOPRINT' ELSE '';
-SET &PR2=IF &PRRET EQ 0 THEN 'NOPRINT' ELSE '';
-SET &PR3=IF &PRZER EQ 0 THEN 'NOPRINT' ELSE '';

TABLE FILE HOLD
SUM SALES &PR1
RETAIL_COST &PR2
ZERO &PR3
BY COUNTRY
END
  





Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

April 24, 2007, 11:56 AM
Shankar
Hi Francis,
This solution looks fine but perhaps it wont be feasible for my report as i've about 25 columns in my report with about 10 BY clauses and 2 ACROSS clauses.
Is there some alternate way ?


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
April 24, 2007, 11:56 AM
Francis Mariani
Forgot about the absolute value! and your way is a little cleaner.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 24, 2007, 12:15 PM
FrankDutch
Francis

If you have a country with +1000 and one with -1000 the sum is zero....
so I need the abs value.

when using 10 by and 2 across values the solution will be a bit more complex, but it would still be a possibility




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7