Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Transpose Column and Row in Crystal Post Reply Post New Topic
Author Message
bigwang916
Newbie
Newbie
Avatar

Joined: 21 May 2012
Location: United States
Online Status: Offline
Posts: 13
Quote bigwang916 Replybullet Topic: Transpose Column and Row in Crystal
    Posted: 22 May 2012 at 12:07pm
Hi everyone,
 
I am having problem with this Crystal Report, I believe the database table structure also plays a role in this. Is it possible to rotate columns to rows and vice versa? For example, I have the following in a report.
 

SubID 

100      Rating               9

100      Comment         Good

200      Rating               5

200      Comment         Okay

300      Rating               1         

300      Comment         Horrible

 

I would like to manipulate the report to look like this:

SubID             Rating             Comment

100                  9                      Good

200                  5                      Okay

300                  1                      Horrible

 
I would like to do this without having to use any cross-tabs. Does anyone know if I can accomplish this?
 
Thank you.
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 22 May 2012 at 11:04pm

Yes you can, with formulae.

whileprintingrecords;
stringvar rating;
if isnull({Rating}) then rating:=rating else rating := {Rating}
 
Do the same for {Comments} and put them in the Details line.
 
Then group on Sub_Id.
 
 Make two more formulae like
 
whileprintingrecords;
stringvar rating;
 
and put {Sub_ID} and the latter two formulae in the group footer.
Then suppress the group header and detail line.
 
IP IP Logged
bigwang916
Newbie
Newbie
Avatar

Joined: 21 May 2012
Location: United States
Online Status: Offline
Posts: 13
Quote bigwang916 Replybullet Posted: 23 May 2012 at 5:26am
Thanks YGG. It seems like I only could get the Comments to show. The result is that Comment and Rating shows duplicates of the Comment Text (i.e, the service was great!, good!, Bad, etc)

SubID             Rating             Comment

100                  Good                   Good

200                  Okay                   Okay

300                  Horrible               Horrible

 
 
 
This is what i have in the details section:
 
@Comment Formula:
whileprintingrecords;
stringvar comment;
if isnull({fieldcommentrating})then comment:=comment else comment := {fieldcommentrating}
 
@Rating Formula:
whileprintingrecords;
stringvar rating;
if isnull({fieldcommentrating})then rating:=rating else rating := {fieldcommentrating}
 
As a note:
fieldcommentrating contains data such as: 9, good, 8 OK, 1, bad etc
fieldname contains data such as : "Rating" and "Comment"
 
Then I grouped by the SUBID.
 
The following formulas were created to put in Group Footer Section (along with SubID field):
 
@Rating2
whileprintingrecords;
stringvar rating;

@Comment2
whileprintingrecords;
stringvar comment;
 
 
 


Edited by bigwang916 - 24 May 2012 at 5:59am
IP IP Logged
bigwang916
Newbie
Newbie
Avatar

Joined: 21 May 2012
Location: United States
Online Status: Offline
Posts: 13
Quote bigwang916 Replybullet Posted: 24 May 2012 at 8:50am
Problem solved! I created a Running Total Field to summarize my @rating (Maximum). Also, under "Reset" check "On change of group and place this field in the Group Footer. This pretty much did the trick since the max is 1 rating per subID.Approve
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 28 May 2012 at 4:53am

if isnull({fieldcommentrating})then comment:=comment else comment := {fieldcommentrating}

if isnull({fieldcommentrating})then rating:=rating else rating := {fieldcommentrating}

You would get the same for both Comment and Rating because you used  
{fieldcommentrating} for both. I had assumed these were two different fields. If you separated '9, good' into rating 9, comment 'good', you would have got them both into the footer as you wanted
IP IP Logged
bigwang916
Newbie
Newbie
Avatar

Joined: 21 May 2012
Location: United States
Online Status: Offline
Posts: 13
Quote bigwang916 Replybullet Posted: 29 May 2012 at 1:31pm
Thanks for your help YGG! Thumbs%20Up
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.