Focal Point
[SOLVED] Ordering Row Values

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

February 09, 2018, 02:49 PM
srajeevan
[SOLVED] Ordering Row Values
Hi,
I have a report as below.
  
Product   	Sales    Count
Product1  	xxx      zzz 
Product2  	yyy      rrr
Product3  	zzz      hhh
product4        bbb      nnn
product5        ccc      jjj
Total-A         aaa      vvv
Total-B         ddd      lll


Total-A should come after the row Product3 and Total-B should come as the last row.
I have used a sequence operation for ordering columns via GUI
Since i have used lots of hold files in my actual report i cannot open this in GUI.
Is there any way to give this sequence for Rows.

This message has been edited. Last edited by: FP Mod Chuck,


WF8206,Windows 7,8,10
HTM,PDF,EXCEL
February 09, 2018, 04:03 PM
MartinY
Since I don't know how your files have been created and because it think that you may have several hold files merged together, the easiest way is to create a row indicator for each.

Sample
TABLE FILE GGSALES
SUM DOLLARS
BY CITY
BY REGION
BY TOTAL COMPUTE TOTID   /I2  = 0;
BY PRODUCT
ON TABLE HOLD AS DETDATA
END

TABLE FILE GGSALES
SUM DOLLARS
BY CITY
BY REGION
BY TOTAL COMPUTE TOTID   /I2  = 2;
BY TOTAL COMPUTE PRODUCT /A16 = 'TOTAL';
ON TABLE HOLD AS TOTDATA
END

TABLE FILE DETDATA
SUM DOLLARS
BY CITY
BY REGION
BY TOTID NOPRINT
BY PRODUCT
MORE
FILE TOTDATA
END


But above can be accomplished with this

TABLE FILE GGSALES
SUM DOLLARS
BY CITY
BY REGION
BY PRODUCT
ON REGION SUBTOTAL
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
February 10, 2018, 02:06 PM
Danny-SRL
srajeevan,
You don't say what Total-A and Total-B are.
Is Total-A the sum of Products 1,2,3 and Total-B the sum of 4,5?
If so, use a DEFINE:
  
DEFINE FILE myfile
T/A1=IF PRODUCT EQ 'Product1' OR 'Product2' OR 'Product3' THEN 'A' ELSE 'B';
END
TABLE FILE myfile
SUM SALES COUNT
BY T NOPRINT
BY PRODUCT
ON T SUBTOTAL
ON TABLE NOTOTAL
END



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

February 12, 2018, 01:27 AM
Chaudhary
Danny-SRL

Nice Thread


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10
February 12, 2018, 10:11 AM
srajeevan
Suppose i have the car file and i am displaying three countries sales(by applying filter) with Country name as first BY Field.
But i want to display those three countries in a specific order not alphabetically as wf does default.
I was hoping for a solution for that.
Daniel: I wont be able to use your solution as Total A and B is not subtotals ,it is another mathematical calculation.
MartinY: I will try your solution of giving a row indicator for each.But product 1 ,product 2 ,product 3 comes from master file and Total Field is a compute field.How can i give row Id for product 1 ,2,3.?Is it possible.


WF8206,Windows 7,8,10
HTM,PDF,EXCEL
February 13, 2018, 05:00 AM
Martin vK
Adding ROWS .. OVER .. to your BY will help to put the values in a specific order.

BY sortfield AS 'coltitle' ROWS value1 [AS 'text1']
OVER value2 [AS 'text2']
[... OVER valuen [ AS 'textn']]
END


WebFocus 8206M, iWay DataMigrator, Windows, DB2 Windows V10.5, MS SQL Server, Azure SQL, Hyperstage, ReportCaster
February 13, 2018, 06:20 AM
Danny-SRL
Srajeevan,

A possibility...
  
-* File srajeevan01.fex
DEFINE FILE CAR
PRODUCT/A20=IF CAR EQ 'JAGUAR' OR 'TOYOTA' OR 'DATSUN' OR 'AUDI' OR 'TRIUMPH' THEN CAR ELSE
            IF CAR EQ 'BMW' THEN 'TOTAL-A' ELSE 
			IF CAR EQ 'MASERATI' THEN 'TOTAL-B' ELSE ' ';
SEQ/I1=DECODE PRODUCT(JAGUAR 1 TOYOTA 2 DATSUN 3 'TOTAL-A' 4 AUDI 5 TRIUMPH 6 'TOTAL-B' 7 ELSE 0); 
Sales/I6 = IF SEQ EQ 1 OR 2 OR 3 OR 5 OR 6 THEN SALES ELSE
           IF SEQ EQ 4 THEN SALES * LOG(SEATS) + RCOST ELSE
		                    (WIDTH + HEIGHT) ** 2;
END
TABLE FILE CAR
SUM Sales CNT.Sales AS Count
BY SEQ NOPRINT
BY PRODUCT
IF PRODUCT NE ' '
END



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

February 13, 2018, 08:05 AM
MartinY
Another option to create row indicator.
My below sample has no sense, but it show the technic of using LAST and avoid of coding all possible values within a DECODE or IF.
But it may not be applicable. Each situation has its own solution.

TABLE FILE CAR
SUM RETAIL_COST
BY TOTAL COMPUTE ROWID /I2 = IF COUNTRY EQ LAST COUNTRY THEN ROWID ELSE ROWID + 1;
BY SEATS
BY COUNTRY
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