×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

One Bar Chart with several BY fields

One Bar Chart with several BY fields

One Bar Chart with several BY fields

(OP)
Hi,

I would like to have a bar chart that sums
one field (y axis) but for 2 fields in the x axis.
For example:

GRAPH FILE MAN_RES
HEADING
" TEST "
SUM TOTAL_EMPLOYEE
BY DEPARTMENT_CODE
BY YYEAR
WHERE (YYEAR IN (2003,2002))
AND DEPARTMENT_CODE IN (19,20,21,22)
ON GRAPH SET GRAPHSTYLE *
setLegendDisplay(true);
setLegendMarkerPosition(0);
setMarkerDisplay(true);
setConnectLineMarkers(false);
setConnectScatterMarkers(false);
setO1LabelDisplay(true);
setO1AxisSide(0);
setO1MajorGridDisplay(true);
setO1MajorGridStyle(0);
setO1MinorGridDisplay(false);
setY1LabelDisplay(true);
setY1AxisSide(0);
setTextFormatPreset(getY1Label(),1);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setY1MinorGridDisplay(false);
setPieFeelerTextDisplay(1);
setTextFormatPreset(getPieSliceLabel(),1);
setPieLabelDisplay(0);
ENDSTYLE
ON GRAPH SET STYLE *
ENDSTYLE
END

The result is 4 charts with YYEAR field on Y axis (both 2002 and 2003),
and Total Employee field on X axis.
(a chart for each Department).
How can I display the same result in one chart?
(I'm using WF 5.1 and MS SQL 2000).

Any help is appreciated.

Regards,
OZ

RE: One Bar Chart with several BY fields

Hi offir,

I'm not sure, but I guess you want to have a chart like this:

^
|----------
|------
|---------
|
|-------------
|---------------
|-------
|
|-----
|--------
|-----------
|
|------------------------>

Is that right?

Eva

RE: One Bar Chart with several BY fields

Two things that you can do with this.
1. Make a field for each Year eg
SUM TOT_EMP_YEAR_1
    TOT_EMP_YEAR_2
    TOT_EMP_YEAR_3
BY DEPT

or just add ON GRAPH SET GMERGE ON to your table request.

RE: One Bar Chart with several BY fields

(OP)
Hi Eva,

Yes, but I need to dice it:
The departments and years should be on the X axis and
the valus on the Y axis.
I saw a thred of yours where u needed to do something
resemblance.

Hi gizzy17,
WF does not seem to recognize the command "SET GMERGE ON" .
It returned: "UNKNOWN KEYWORD IN STYLESHEET FILE AT LINE: 1   ON GRAPH SET GMERGE".
Also, when defining total employee for each year,
I got the result but with a chart for each department.
I need one chart containing all the data.

Did u hear about the APPEND command.
I was told maybe this one can help but I
didn't find any help about it in my books.

Any other ideas?

Thanks a lot,
OZ


RE: One Bar Chart with several BY fields

Hi Oz,

yes, I had something similar. And I solved it like gizzy17. You will have to create the TOT_EMP_YEAR_1,  TOT_EMP_YEAR_2,  TOT_EMP_YEAR_3 with a DEFINE:

DEFINE FILE XYZ
 TOT_EMP_YEAR_1/I11 = IF YYEAR EQ '2001' THEN TOTALEMPLOYEE ELSE 0;
 TOT_EMP_YEAR_2/I11 = IF YYEAR EQ '2002' THEN TOTALEMPLOYEE ELSE 0;
 TOT_EMP_YEAR_3/I11 = IF YYEAR EQ '2003' THEN TOTALEMPLOYEE ELSE 0;
END

And then display the graph with

GRAPH FILE XYZ
 SUM TOT_EMP_YEAR_1
     TOT_EMP_YEAR_2
     TOT_EMP_YEAR_3
 BY DEPARTMENT_CODE
END

(I didn't use the SET GMERGE ON )

Of course to define the years like that is not good. (EQ '2002') Because it will not always be the years 2001, 2002 and 2003. You'll have to  get the years into a variable first so that you don't write them explicitly down.

Eva

RE: One Bar Chart with several BY fields

You could define a field which concatenates your year field and department field into one field.

i.e. if you department field is an A4 and year is an A4 then do

DEFINE FILE filename
DEPT_YR/A8=YEAR || DEPT;
END
GRAPH FILE filename
SUM
TOTAL_EMPLOYEE
BY DEPT_YR

etc

Regards

Tewy

RE: One Bar Chart with several BY fields

Oz,

It looks to me that you put the gmerge command in the stylesheet.  This needs to go outside of the stylesheet as follows.

GRAPH FILE MAN_RES
SUM TOTAL_EMPLOYEE
BY DEPARTMENT_CODE
BY YYEAR
WHERE YYEAR EQ 2002 OR 2003
AND DEPPARTMENT_CODE EQ 19 OR 20 OR 21 OR 22
ON GRAPH SET GMERGE ON
ON GRAPH SET GRAPHSTYLE *
....
ENDSTYLE
END

You should also be able to use "SET GMERGE = ON" prior to the "GRAPH FILE".

RE: One Bar Chart with several BY fields

(OP)
Hi all

It works. (I used the define for the years).
I still get the error for the GMERGE command.

Thanks u very very much!!

OZ

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close