Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a field name in a crosstab row, instead of field value

Status
Not open for further replies.

handle1134

Programmer
Jul 20, 2006
24
RO
Hello

I want in a crosstab to add some fields in rows, but the field itself, not its values. For example:

Column: 2002 2003 2004 2005 Average

ROW:
StudentID:
Name:
Address:
Grade:
...

WorkerID:
Name:
Address:
Salary:
...

Notice that there are two different tables, Student and Worker, with different types of fields (grade / salary).
Do you know how to do this?
10x
 
Do you mean you are using v. 10? Do you have the crosstab already working except that you need row labels? Please identify the fields you are using for row, column, and summaries.

-LB
 
Thanks for answer.

I use Crystal Reports XI. I am trying to make a report witch contains data from multiple tables, and display it as a crosstab. It is not working as i would like to.
I want on row to have the name of the fields involved grouped by type, where each type has different fields.
As in my first example, Student and Worker are different tables with different fields, witch consists the row.
On the column there is time line, like this:

2002 | 2003 ...
Spring Autumn | Spring Autumn ...

And summaries are the exact values (for names, addresses or IDs) or average values (for grades or salaries).

The tables are:

STUDENT:
- studentID
- name
- address
- grade

WORKER:
- workerID
- name
- address
- salary

The question is how do I display a list of fields in row (as labels), and not a list of values of a certain field...
 
Do you actually have a "Type" field with "Worker" and "Student" as instances? What do you have working so far? Getting the labels is the easy part.

To make the crosstab work with these tables, I think you would need to use a command as a datasource. Go to database->database expert->your datasource->add command and enter something like:

Select 'Student' as type, student.`studentID`, student.`name`,student.`address`,student.`grade`
From `student` student
UNION ALL
Select 'Worker' as type, worker.`workerID`, worker.`name`,worker.`address`, worker.`salary`
From `worker` worker

This assumes that corresponding fields in each half of the union statement are of the same datatype. You haven't shown all the relevant tables, as there are no date fields shown in your post, and these would have to be built into each side of command statement.

Then you would insert {commmand.type} as your row field, {command.date} as the column field (on change of year), {command.semester} or {command.quarter} as the second column field. Then for the summaries you would use maximums. To get the row labels, go to the customize style tab->summarized fields->check "show labels".

-LB
 
Ok, that was it! I knew it could be done, but just now i realised what multiple summarized fields can do (and 'show labels' checked).
So i put a new summarized field for every field i need in the Student and Worker tables (on row), with a condition to put only the relevant field for every table (Student have a null salary and a not null grade).
Now in the time line, a can put two fields in the column (year & semester) or put 2 series of fields in summarized, one for every semester. But i see that the summarized fields can be or horizontal either verical, and not both (smth like a rectangular area 2 x 3 values in the cell, for example).
So i'll use two fields in the column.
It looks fine now, hope the boss will be satisfied... :)
10x

 
If you had used the union statement, you would have needed only one summary per ID, name, address, and grade/salary, since they would have populated the same field, and the row (type) would have differentiated the values.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top