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     How to sort month name in across field

Read-Only Read-Only Topic
Go
Search
Notify
Tools
How to sort month name in across field
 Login/Join
 
Member
posted
Hi All,

Happy New Year

I have table called month_sales, in which field names are month_name(Jan,Feb,Mar...Dec) and monthsales field with numeric values and year field with 2004,2005,2006
in the selection screen if i select monthname as Jul and year as 2005 i should get the output as

Jul Aug Sep Oct Nov Dec .........Jun
2005 25 30 10 25 10

TABLE FILE month_sales
PRINT
monthsales
BY year
ACROSS month_name

Problem: if i say ACROSS month_name it sorts according to Alphabetical order

Help me in doing custom sort based on the selection parameter.

Thanks in advance
RajTA


WebFOCUS 7.x
Windows
Excel,PDF,HTML
 
Posts: 3 | Location: Bangalore | Registered: December 17, 2007Report This Post
Virtuoso
posted Hide Post
Raj

If you take a look at this site you will see some function buttons.
the 3th says "Find" try that to find subjects already discussed.

It's not that we do not want to tell this agian, but it might be quicker if all the new starters would know all the smart things here that are helpfull.

Now your question.

There are many ways to do this.
If your date was a real date field your across would work as you wanted.
So you can convert it to a realdate.

An other solution is create a sortfield by a decode.

DEFINE FILE xxx
SORTFIELD/I2=DECODE MONTH(JAN 1 FEB 2 MAR 3 ... Oct 10 Nov 11 Dec 12);
END


In the report you add an extra across before the across month_name.

You also can spell out the names in the sequence you want

ACROSS month_name COLUMNS JAN AND FEB AND MAR etc




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Another alternative would be to define the month as a date, ie,
DEFINE FILE XXX
SORTFIELD/Mt = SALESDATE;
END

This would assume SALESDATE is the date in a smart date format representing say the date of a sale if it were in the master. Works in version 7.2. Then you get a pretty heading which sorts on the underlying order.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Member
posted Hide Post
Thanks Frank and Leah

But Frank i have already done that and it is working but based on the month selection it should change.
for example
if i select May month and 2007 year

it should come from

Jun Jul Aug Sep Oct Nov
if i select Mar

is should come from
Apr May Jun Jul

and so on
based on the inpur parameter i select i should get the next month name from the Across field
and the datatype for the month_name field is varchar

Thanks
Raj


WebFOCUS 7.x
Windows
Excel,PDF,HTML
 
Posts: 3 | Location: Bangalore | Registered: December 17, 2007Report This Post
Virtuoso
posted Hide Post
Raj

You can do this.

If you select a month that should be the starting month.
suppose this is may (number5)

-SET &SORT2/I2=DECODE &MONTH(JAN 1 FEB 2 MAR 3 ... Oct 10 Nov 11 Dec 12);
DEFINE FILE xxx
SORT1/I2=DECODE MONTH(JAN 1 FEB 2 MAR 3 ... Oct 10 Nov 11 Dec 12);
SORTFIELD/I2=IF SORT1 GE &SORT2 THEN SORT1-&SORT2+1 ELSE  SORT1-&SORT2+13;
END


Now when you select MAY the new sequence will be MAY=1 JUN=2 etc

I hope this will help some steps...




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Platinum Member
posted Hide Post
Most of the time we'll handle it with a NOPRINT.

ACROSS MONTHS NOPRINT
ACROSS MONTH_DATEX AS ''

In this example MONTHS is the actual date (or datetime) column, and MONTH_DATEX is the formatted (display) version of the month. Ultimately though, if they are a DATE or DATETIME format, they should sort correctly. You may want to look at your formats...



Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio
Testing: <none>
Using MRE & BID.  Connected to MS SQL Server 2005
Output Types: HTML, Excel, PDF
 
Posts: 230 | Location: Wichita, KS | Registered: May 27, 2005Report This Post
Virtuoso
posted Hide Post
Trav

Your suggestion is ok, but the original question was a bit different, they want a flexibel sorting where the starting month is influenced by the end user.

My solution could do that. the straitforward solution was not suitable here.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Platinum Member
posted Hide Post
Yeah I didn't catch that his report could span years -- if not, then it could be simplified but obviously that was not the case (and rarely is!). I got hung up on the fact that it was sorting alphabetically and thought it was a format issue -- which for the OP I would still pay close attention to the difference in dates, datetimes, and alphas.

In retrospect, Frank your solution is pretty much spot-on to what we've done here with similar reports and graphs and works nicely in both scenarios.



Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio
Testing: <none>
Using MRE & BID.  Connected to MS SQL Server 2005
Output Types: HTML, Excel, PDF
 
Posts: 230 | Location: Wichita, KS | Registered: May 27, 2005Report This Post
Guru
posted Hide Post
RajTA

Assuming you have field like:

 MTH/YYMD 


then you can use:

 ACROSS MTH/YYMtrD 


This sorts MTH as a YYMD field so 20071231 comes before 20080101 but displays according to the YYMtrD in the ACROSS statement so you get full names.

Fernando


Prod WF 8.1.04, QA WF 8.2.03, Dev WF 8.2.03
 
Posts: 278 | Registered: October 10, 2006Report This Post
Member
posted Hide Post
Hi All,

Thanks for the answers but

I have tried with the following code but it gives the output sorted according to month_name from febrauary to January,
but if i select month april in the html selection screen year as 2005 then the output month should start from may jun jul oct.


month name should dynamically change the order.

in across columns instead of hardcoding can i do any parameteration declare parameter which takes care of the order.

The column MONTHS is varchar datatype in SQL Server



DEFINE FILE TIME_DIM
MONTH/A20 = DECODE MONTHS (12 'Jan' 1 'Feb' 2 'Mar' 3 'Apr' 4 'May' 5 'Jun' 6 'Jul' 7 'Aug' 8 'Sep' 9 'Oct' 10 'Nov' 11 'Dec');
END
TABLE FILE TIME_DM
SUM
EXP_AMT NOPRINT
USE_AMT NOPRINT
COMPUTE Rate/P20.2 = EXP_AMT / USE_AMT;
BY REGION
BY YEAR
ACROSS MONTH COLUMNS 'Feb' AND 'Mar' AND 'Apr' AND 'May' AND 'Jun' AND 'Jul' AND 'Aug' AND 'Sep' AND 'Oct' AND 'Nov' AND 'Dec' AND 'Jan'
WHERE YEAR EQ '2003';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
GRID=OFF,
FONT='TIMES NEW ROMAN',
SIZE=10,
COLOR='BLACK',
BACKCOLOR='NONE',
STYLE=NORMAL,
$
ENDSTYLE
END


WebFOCUS 7.x
Windows
Excel,PDF,HTML
 
Posts: 3 | Location: Bangalore | Registered: December 17, 2007Report This Post
Expert
posted Hide Post
Did you look at Frank's example above? It has everything you need for your code to work. The only thing I think you'd have to change is that you would want to add 1 to &SORT2 in his example because you want 1 month greater than the one selected.

In your code example, you are not using the input from the html screen at all.

And the idea is to sort across using that constructed SORTFIELD noprinted.

Please play around with Frank's code and see if you can't make it work for you.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Expert
posted Hide Post
You only have to have a basic level of understanding of FOCUS and read what folks write to get your results.

Use "real" dates (as Frank mentioned) also known as "smart dates" i.e. those with a format of YYMD or the like. Leah actually gave you what you needed but you seemed to ignore it? If you didn't understand then perhaps you should push for some basic training with IB from your manager?

The following code gives a years worth of data from apr 1996 to mar 1997 and will automatically show different months as the across column heading when you change the selected date range -

DEFINE FILE GGSALES
YEAR/YY  = DATE;
MONTH/Mt = DATE;
END
TABLE FILE GGSALES
SUM DOLLARS
ACROSS YEAR NOPRINT
ACROSS MONTH AS ''
BY REGION
BY ST
BY CATEGORY
WHERE YEAR FROM 1996 TO 1997
WHERE DATE FROM 19960401 TO 19970331
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
GRID=OFF, $
ENDSTYLE
END

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
Like everyone has previously pointed out, the months are sorted correctly in this example because the month column (MTH) is defined as a "Smart Date" and not as alpha.

DEFINE FILE TIME
DATE1/A8YYMD = DATE;
MTH/Mtr = DATE1;
DUMMY1/P5 = 1;
END
TABLE FILE TIME
SUM
DUMMY1
ACROSS MTH

ON TABLE SET HTMLCSS ON
ON TABLE SET STYLESHEET *
BORDER=1, BORDER-COLOR=SILVER,
FONT='ARIAL', SIZE=8, $
END


Result:

  
MTH 
January February March April  May June July August September October November December 
   1600     1462  1600  1550 1600 1551 1600   1600      1550    1600     1550     1600 


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report 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     How to sort month name in across field

Copyright © 1996-2020 Information Builders