Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Switch lines and columns

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Switch lines and columns
 Login/Join
 
Member
posted
Hi everyone,

I have a report that works perfectly fine, but now I have to allow the user to switch lines to columns. Is there any quick way of doing this?

Thanks in advance.


__________________________
Dev: WebFOCUS 7.6.8
OS: Windows XP
Output: *ALL
 
Posts: 12 | Registered: January 17, 2012Report This Post
Virtuoso
posted Hide Post
You are trying to pivot your data from lines to columns. How "quick" a way depends entirely on your data and what the layout is and has to be.

If the data lends itself to it, you may just use ACROSS.

If not, you'll have to DEFINE data buckets for each "column" using IF statements to decide what value goes into which column. You can then run a SUM request (probably with no BY's) and you would get a line with many columns ... each of them representing what was a separate line before.

Without knowing exactly what you want to see is sort of hard to make appropriate suggestions.

Can you work out an example with the CAR table simulating what you have today (lines-based report) and mock something up as to how the output would look now in column mode?



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Member
posted Hide Post
I tried a few things on my own, but didn't get anything satisfying... or even close to what I need...

So here's some code I made up to show you.


-* Building a table with fake data
-REPEAT LOOP.DEF FOR &I FROM 1 TO 5;

DEFINE FILE DUMMY
	DESC/A20 = 'Description' | '&I';
	COLOR/A20 = 'Color' | '&I';
	YEAR/A20 = '200' | '&I';
END

-SET &TBL = 'HOLDFILE' | &I;

TABLE FILE DUMMY
PRINT *
	DESC AS 'Description';
	COLOR AS 'Color';
	YEAR AS 'Year';
	ON TABLE HOLD AS &TBL.EVAL FORMAT ALPHA
END

-RUN
-LOOP.DEF;
-* Now we have 5 HOLDFILEx tables.

-* Putting all the data together
TABLE FILE DUMMY
PRINT *
	DESC
	COLOR
	YEAR
	WHERE YEAR = '0';
ON TABLE HOLD AS TBL_DONNEES
-SET &J = 1;
-REPEAT LOOP.PLUS FOR &J FROM 1 TO 5;
-SET &V_HLD01 = 'HOLDFILE' | &J;
MORE
FILE &V_HLD01.EVAL
-LOOP.PLUS;
END
-RUN

-* Displaying the data by column
TABLE FILE TBL_DONNEES
PRINT 
	DESC
	COLOR
	YEAR
END
-RUN
-EXIT


It gives something like this (sorry I couldn't format):
DESC . . . . COLOR . YEAR
Description1 Color1 2001
Description2 Color2 2002
Description3 Color3 2003
Description4 Color4 2004
Description5 Color5 2005

What I need would be to swap lines and columns:
DESC . Description1 . Description2 . ...
COLOR. Color1 . . . . . Color2 . . . . ...
YEAR . . 2001 . . . . . . 2002 . . . . . ...

Sorry I won't post the original code, it's a trillion lines long...


__________________________
Dev: WebFOCUS 7.6.8
OS: Windows XP
Output: *ALL
 
Posts: 12 | Registered: January 17, 2012Report This Post
Virtuoso
posted Hide Post
Try this:

TABLE FILE TBL_DONNEES
 SUM COLOR
 OVER YEAR
 ACROSS DESC
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Virtuoso
posted Hide Post
Or this:

TABLE FILE TBL_DONNEES
 SUM DESC
 OVER COLOR
 OVER YEAR
 ACROSS DESC NOPRINT
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Virtuoso
posted Hide Post
quote:
Sorry I won't post the original code, it's a trillion lines long...


No worries. We wouldn't been able to review it either Wink

Fanfanprovok, your sample code does not work as it relies on a DUMMY table whose creation code you did not provide.

Anyway, this seems to be feasible with ACROSS and OVER.

See my sample code below to give you an idea of something you can start with:

TABLE FILE CAR
PRINT COUNTRY
      CAR
      MODEL
HEADING
"Vertical Layout"
ON TABLE SET PAGE NOPAGE
END


TABLE FILE CAR
SUM CAR OVER MODEL
ACROSS COUNTRY AS ''
HEADING
"Horizontal Layout"
ON TABLE SET PAGE NOPAGE
END




Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Member
posted Hide Post
quote:
Originally posted by Dan Satchell:
Or this:

TABLE FILE TBL_DONNEES
 SUM DESC
 OVER COLOR
 OVER YEAR
 ACROSS DESC NOPRINT
END


That's EXACTLY what I needed! Thank you!!


...


But now the problem is that I can't SQUEEZE my columns...!!!

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


__________________________
Dev: WebFOCUS 7.6.8
OS: Windows XP
Output: *ALL
 
Posts: 12 | Registered: January 17, 2012Report This Post
Member
posted Hide Post
The documentation says that OVER applies to HTML and PDF. Any idea how to do it in Excel? SUM doesn't seem to apply to EXL2K either...


__________________________
Dev: WebFOCUS 7.6.8
OS: Windows XP
Output: *ALL
 
Posts: 12 | Registered: January 17, 2012Report This Post
Virtuoso
posted Hide Post
quote:
Any idea how to do it in Excel? SUM doesn't seem to apply to EXL2K either...


Did you actually try this in 7.6 and did not work?

I just ran the sample code I had provided in 7.7.03 using EXL2K output and it works as expected.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Member
posted Hide Post
No i didn't have time to try it in EXCEL. I've been busy trying to make the real thing display in lines... still no satisfaction...! Here's what I have so far. The ACROSS doesn't seem to work. In which cases would an ACROSS not work? Sorry I'm not posting the whole thing, but as I said earlier, it's quite huge...

 
...
ON TABLE HOLD AS SOLDE_GL_FINAL_FOR_TESTS FORMAT ALPHA
END

TABLE FILE SOLDE_GL_FINAL_FOR_TESTS
SUM

-SET &CNT_COL = 0;
-SET &CNT_COLTOTAL = 0;

-FINAL_LP2

-SET &CNT_COL			= &CNT_COL + 1;
-SET &COL_NUM 			= 'COLUMN' || &CNT_COL || '_NUM';
-SET &COL_DENOM 		= 'COLUMN' || &CNT_COL || '_DENOM';
-SET &COL_TMP			= 'COL_TMP'|| &CNT_COL;
-SET &COND_AMOUNT_TOT = IF &IS_IN_PERCENTAGE.EVAL EQ 1 
-   THEN 'COMPUTE &COL_TMP.EVAL/D17.2B% = (&COL_NUM.EVAL/&COL_DENOM.EVAL) * 100;'
-   ELSE 'COMPUTE &COL_TMP.EVAL/D17.2B = (&COL_NUM.EVAL/&COL_DENOM.EVAL);';

-* For lines after the first, add "OVER".
-IF &CNT_COLTOTAL EQ 1 THEN GOTO FST_LINE;
OVER
&COND_AMOUNT_TOT.EVAL AS '&COL_TMP';
-GOTO NEXT_LINE;

-FST_LINE
&COND_AMOUNT_TOT.EVAL AS '&COL_TMP';
-NEXT_LINE

-* Goto next line.
-IF &CNT_COLTOTAL LT &NBCOL_TOTAL.EVAL GOTO FINAL_LP2;

-* Apply horizontal sort.
ACROSS 'COL_TMP1' NOPRINT

END
-RUN
-EXIT



When I run this code, the output is like this, which you be good if it didn't do a sum:
COL_TMP1 769,335.27
COL_TMP2 (481,135.99)
COL_TMP3 292,001.49


When I replace SUM with PRINT, the output looks like this, which would be perfect if it wasn't all on the same column.:

COL_TMP1 12,389,526.17
COL_TMP2 .00
COL_TMP3 .00
COL_TMP1 863,804.17
COL_TMP2 .00
COL_TMP3 .00
COL_TMP1 .00
...

Any ideas?

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


__________________________
Dev: WebFOCUS 7.6.8
OS: Windows XP
Output: *ALL
 
Posts: 12 | Registered: January 17, 2012Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Switch lines and columns

Copyright © 1996-2020 Information Builders