Focal Point
[SOLVED] Conditional Heading based on report ROW-TOTAL result

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

April 18, 2011, 04:18 PM
tiger
[SOLVED] Conditional Heading based on report ROW-TOTAL result
Hi, i want to find a way to have a conditional header based on the result of the grandtotal of my report.
example: if the grandtotal of sales in the report is Greater then 1 000 000$ the conditional text should be "TARGET REACHED, BONUS GRANTED"



TABLE FILE SALES

SUM
PROD1_SALES AS 'PROD1'
PROD2_SALES AS 'PROD2'
PROD3_SALES AS 'PROD3'

BY YEAR

HEADING
"SALES REPORT "

-*------------------------
-*i know it does not work like that but i would like to have something like..

-IF ROW-TOTAL GE 1000000 THEN GOTO BONUS ELSE GOTO NOBONUS
-BONUS
"TARGET REACHED, BONUS GRANTED"
-NOBONUS

-*----------------------------

ON TABLE SET PAGE-NUM OFF
ON TABLE ROW-TOTAL AS 'SALES BY YEAR'
ON TABLE COLUMN-TOTAL AS 'TOTAL SALES'
ON TABLE PCHOLD FORMAT PDF
END

the report ouput should look something like this

SALES REPORT
TARGET REACHED, BONUS GRANTED

YEAR......PROD1...PROD2...PROD3......SALES BY YEAR
2009......10 000...20 000...200 000......230 000
2010......20 000...40 000...300 000......360 000
2011......30 000...60 000...400 000......490 000
TOTAL SALES..60 000...120 000...900 000......1 080 000

Please help.
thanks.

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


7.6.2, windows xp
April 18, 2011, 05:19 PM
Crymsyn
Try this

 TABLE FILE SALES
SUM 
PROD1_SALES
PROD2_SALES
PROD3_SALES
COMPUTE GRANDTOT/D19.2=IF YEAR EQ LAST YEAR THEN (PROD1_SALES + PROD2_SALES + PROD3_SALES) ELSE ((PROD1_SALES + PROD2_SALES + PROD3_SALES) + GRANDTOT);
BY YEAR
ON TABLE HOLD AS HOLDSALES
END

TABLE FILE HOLDSALES
PRINT
PROD1_SALES AS 'PROD1'
PROD2_SALES AS 'PROD2'
PROD3_SALES AS 'PROD3'

BY YEAR

HEADING
"SALES REPORT "
HEADING
"TARGET REACHED, BONUS GRANTED"
WHEN SUM.GRANDTOT GE 1000000;

ON TABLE SET PAGE-NUM OFF
ON TABLE ROW-TOTAL AS 'SALES BY YEAR'
ON TABLE COLUMN-TOTAL AS 'TOTAL SALES'
ON TABLE PCHOLD FORMAT PDF
END 



WF: 8201, OS: Windows, Output: HTML, PDF, Excel
April 19, 2011, 01:31 PM
pvparuc
Try this.. Hope this is what you need...

TABLE FILE CAR
PRINT
DEALER_COST
RETAIL_COST
COMPUTE TOTAL_COST/D12 = DEALER_COST+RETAIL_COST;
BY CAR
ON TABLE COLUMN-TOTAL AS 'TOTAL SALES'
HEADING
"SALES REPORT "
-IF TOT.TOTAL_COST LE 100 THEN GOTO SHOWCOL1 ELSE GOTO SHOWCOL2;
-SHOWCOL1
"COL1"
-SHOWCOL2
"COL2"
END


Release: Webfocus 7.6.11
OS/Platform: Windows
Output: HTML, EXL2K
April 21, 2011, 02:04 PM
tiger
hi guys,
I finaly got this.

CRYMSYN:
tried WHEN SUM.GRANDTOT GE.... but it did not work on HEADING or ON TABLE SUBHEAD. I tested it on subhead/subfoot and it worked fine.

PVPARUC:
i tried the -IF phrase the logic worked great but it did not recognize the TOT.FIELDXXX

so i tried something like this

TABLE FILE HOLD_xxx
SUM
GRANDTOT/I11
ON TABLE NOTOTAL
ON TABLE SAVE
END
-RUN;
-READ SAVE &VAR1.I11.
-RUN;

then I took the &VAR1 and put it into something like

HEADING
"SALES REPORT "
-IF &VAR1 LE 100 THEN GOTO SHOWCOL1 ELSE GOTO SHOWCOL2;
-SHOWCOL1
"COL1"
-SHOWCOL2
"COL2"
END

It finaly works!!!!!
thank you


7.6.2, windows xp
April 24, 2011, 06:38 AM
Danny-SRL
Tiger,

A few comments:

Your solution is ok when the number of records you are reading is not too high. However understand that you are reading your file twice which could create problems of response time.

PVPARUC's solution is a contradiction in terms: he is trying to mix a TABLE request with Dialog Manager. Dialog Manager procedure commands are executed BEFORE the TABLE request, hence there is no way that it can use the TOT.TOTAL_COST field. One should understand that DM is a pre-processor.

This, I think, is a FOCUS solution:
-* File Tiger01.fex
TABLE FILE CAR
SUM SALES NOPRINT
COMPUTE MYHEAD/A35 =IF SALES GT 100000 THEN 'TARGET REACHED, BONUS GRANTED' ELSE 'TARGET NOT REACHED, NO BONUS'; NOPRINT
PRINT SALES
BY COUNTRY
ON TABLE COLUMN-TOTAL
HEADING
"<MYHEAD "
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF