Focal Point
dynamic By fields

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

May 12, 2008, 02:30 PM
shravan
dynamic By fields
Hi,

I am new to WebFOCUS. I am trying to group by/ total dynamically depending on the parameters passed.

For example:
If I pass &GROUPBY = 1 as a parameter, then I want the report to have "Region" as By field(and subtotal accordingly).
&GROUPBY = 2 then 'Area'(as By field)
&GROUPBY = 3 then 'Branch'(as By field)
&GROUPBY = 4 then 'Businsess'(as By field)...etc.,.

Is there a way to this ?

Thanks.


7.7.03, Windows 7, SQL Server 2005
May 12, 2008, 02:37 PM
RSquared
Shravan,

You can do this by coding such as
-SET &BYSORT=IF &GROUPBY EQ '1' THEN 'Region'
- ELSE IF IF &GROUPBY EQ '2' THEN 'Area' ETC.

Then in your .fex do a
PRINT FIELD1 ...
BY &SORTBY.


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
May 12, 2008, 02:38 PM
Gizmo
If the GROUPBY parameter contains the name of the field, then it would be as simple as asigning &GROUPBY to be the sort field. If GROUPBY is a number, you will have to create a new parameter with the actual name.

From the painter, you can then drag the parameter onto the report just as it were another field.


-SET &SORTFLD = DECODE &GROUPBY (1 'REGION'
-  2 'AREA' 3 'BRANCH' 4 'BUSINESS');

TABLE FILE myfile
PRINT
  field1
  field2
BY &SORTFLD
END




Windows: WF 7.6.2: SQL Server 2008 R2
May 12, 2008, 04:00 PM
shravan
It works ! Thanks RSquared. Thanks Gizmo. It was great help !

I may have another question. If the user can pass 1,2 & 3 the report should be able to group by Region then by Area and then by Branch. I am going to try this by myself (and may be come back Smiler).


7.7.03, Windows 7, SQL Server 2005
May 13, 2008, 01:54 PM
shravan
I am not able to find the correct syntax to sort by mutliple fields dynamically.

For example if the user passes 1, the report should be able to sort BY just Region, if the user passes 10, the report should be able to sort BY Region and also Area. Is it possible ? Can somebody please advise ?

Thanks.


7.7.03, Windows 7, SQL Server 2005
May 13, 2008, 02:23 PM
Darin Lee
I don't know what 1 and 10 are , so i don't know how to answer. Best way to do what you need is to set up some dialogue manager commands. If you are passing three parameters, each of which can have a value or not, then
-SET &BYFLD1=IF '&parm1.EVAL' NE '' THEN 'BY &parm1 SUBTOTAL' ELSE '';
-SET &BYFLD2=IF '&parm2.EVAL' NE '' THEN 'BY &parm2 SUBTOTAL' ELSE '';
-SET &BYFLD3=IF '&parm3.EVAL' NE '' THEN 'BY &parm3 SUBTOTAL' ELSE '';


Then in your report you can just say
&BYFLD1.EVAL
&BYFLD2.EVAL
&BYFLD3.EVAL

If the parms have values, you get sorts and subtotals. If the parms are blank, you don't get sorts and subtotals.

This message has been edited. Last edited by: Darin Lee,


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
May 13, 2008, 03:10 PM
shravan
Darin,

Even though I did not communicate my question correctly, you understood it. The solution you suggested was what I needed. Thank you very much. It's just been 2 days since I've joined this forum. I already started liking it.

Thanks.


7.7.03, Windows 7, SQL Server 2005