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] Conditional BY fields in a report
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Conditional BY fields in a report
 Login/Join
 
Member
posted
I have a need for the user to be able to select a variable number of BY fields. They might need 1 level, 2 levels, 3 levels, etc. If they only select values for the first variable then the report needs only 1 BY if they select 2 then the report needs 2 BY columns, etc. Below is a sample .fex but they would need to select values for all three variables.

-* Default Mode: Report Painter

-SET &CNT1 = &CTR.(MODEL,CAR,COUNTRY).CNT1.;
-SET &CNT2 = &CTR1.(MODEL,CAR,COUNTRY).CNT2.;
-SET &CNT3 = &CTR2.(MODEL,CAR,COUNTRY).CNT3.;

SET EXPANDBYROW = ON
TABLE FILE CAR
SUM
CAR.BODY.DEALER_COST
CAR.BODY.RETAIL_COST
BY &CNT1
BY &CNT2
BY &CNT3
ON TABLE SET EXPANDABLE ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
ENDSTYLE
END

I've searched the forum and cannot find a solution.

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8009, All Outputs
 
Posts: 26 | Registered: February 28, 2013Reply With QuoteReport This Post
Expert
posted Hide Post
  
-DEFAULTS &CNT1 = 'FOC_NONE', &CNT2 = 'FOC_NONE', &CNT3 = 'FOC_NONE'
-PROMPT &CNT1.(<NONE,FOC_NONE>,<MODEL,MODEL>,<CAR,CAR>,<COUNTRY,COUNTRY>.Select Sort 1.
-PROMPT &CNT2.(<NONE,FOC_NONE>,<MODEL,MODEL>,<CAR,CAR>,<COUNTRY,COUNTRY>.Select Sort 2.
-PROMPT &CNT3.(<NONE,FOC_NONE>,<MODEL,MODEL>,<CAR,CAR>,<COUNTRY,COUNTRY>.Select Sort 3.
-SET &SORT1 = IF &CNT1 NE 'FOC_NONE' THEN 'BY ' | &CNT1 ELSE '';
-SET &SORT2 = IF &CNT2 NE 'FOC_NONE' THEN 'BY ' | &CNT2 ELSE '';
-SET &SORT3 = IF &CNT3 NE 'FOC_NONE' THEN 'BY ' | &CNT3 ELSE '';

SET EXPANDBYROW = ON
TABLE FILE CAR
SUM
CAR.BODY.DEALER_COST
CAR.BODY.RETAIL_COST
&SORT1
&SORT2
&SORT3
ON TABLE SET EXPANDABLE ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
ENDSTYLE
END
-EXIT 


Not tested, we don't use -PROMPT, we use HTML


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1965 | Location: Centennial, CO | Registered: January 31, 2006Reply With QuoteReport This Post
Member
posted Hide Post
That will work, Thanks for the quick response.


WebFOCUS 8009, All Outputs
 
Posts: 26 | Registered: February 28, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
  
-PROMPT &CNT1.(<NONE,FOC_NONE>,<MODEL,MODEL>,<CAR,CAR>,<COUNTRY,COUNTRY>.Select Sort 1.
-PROMPT &CNT2.(<NONE,FOC_NONE>,<MODEL,MODEL>,<CAR,CAR>,<COUNTRY,COUNTRY>.Select Sort 2.
-PROMPT &CNT3.(<NONE,FOC_NONE>,<MODEL,MODEL>,<CAR,CAR>,<COUNTRY,COUNTRY>.Select Sort 3.

SET EXPANDBYROW = ON
TABLE FILE CAR
SUM
CAR.BODY.DEALER_COST
CAR.BODY.RETAIL_COST
BY &CNT1
BY &CNT2
BY &CNT3
ON TABLE SET EXPANDABLE ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
ENDSTYLE
END

When WF replaces the paramters with their values, the lines with BY FOC_NONE will not be placed in the FOCSTACK. Hence the simplicity.


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

 
Posts: 1954 | Location: Tel Aviv, Israel | Registered: March 23, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
The easiest way to do this is in DevStudio.
You first put any number of BY fields on the canvas, then multi-select them, and depress the
button next to the WHERE/IF. It asks for some options and all the coding is done for you.


Release 7.6.9
Windows
HTML
 
Posts: 226 | Registered: June 08, 2003Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Conditional BY fields in a report

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