Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Designing Report Post Reply Post New Topic
Author Message
Prince
Newbie
Newbie
Avatar

Joined: 05 Oct 2011
Location: Kenya
Online Status: Offline
Posts: 4
Quote Prince Replybullet Topic: Designing Report
     Posted: 05 Oct 2011 at 5:56am
Hello,
I have multiple rows from a table and want the report to display in a single line for rows with a similar date..

 This is how the data looks in on a report i had generated using standard report:

Date               Grade Weight1   Weight2    Sum
1/10/2011         A          22           33           65
1/10/2011         B           20           30           60
2/10/2011          A          10         21             31
2/10/2011          B          10         22             32


THIS IS HOW I WANT THE REPORT TO LOOK LIKE:

 

DATE

A

B

Weight1

Weight2

Sum

Weight1

Weight2

Sum

1/10/2011

22

33

65

20

30

60

2/10/2011

10

21

31

10

22

32

 
Your help will be highly appreciated...







IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 05 Oct 2011 at 6:22am
What are the fields that you are using?
 
you will need to GROUP by Date, then write formulas to display your results horizontally.
 
as you know, Crystal Reports displays data vertically.
 
again, let me know what fields are available to you and which ones you are using.
 
If it was me doing it, I would GROUP by Date then create formulas like:
 
@Aweight1
IF {TABLE.GRADE}="A" THEN {TABLE.WEIGHT1}
 
@Aweight2
IF {TABLE.GRADE}="A" THEN {TABLE.WEIGHT2}
 
@Aweightsum
IF {TABLE.GRADE}="A" THEN {TABLE.SUM}
 
@Bweight1
IF {TABLE.GRADE}="B" THEN {TABLE.WEIGHT1}
 
etc etc.......
 
once you have all your formulas, insert them into your report, and summarize them by your DATE group.
 
so your design view should look similar to this:
 
GROUPH1 - [group.name]    [sum@Aweight1]    [sum@Aweight2]   [sum@Aweightsum]    [sum@Bweight1]
 
 
etc etc
 
 
Regards,

Michael Jones
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 05 Oct 2011 at 7:56am
you could probably use a cross tab style report...but cross tabs only deal with summaries so it will want to add or count or something like that (I don't use cross tabs at this job, so they're a bit fuzzy)
 
HTH
IP IP Logged
Prince
Newbie
Newbie
Avatar

Joined: 05 Oct 2011
Location: Kenya
Online Status: Offline
Posts: 4
Quote Prince Replybullet Posted: 13 Oct 2011 at 5:12am


Grade name in table 2 and 3 is picked from table 1 as a using a FK..
Sum in the report should sum Weight1 and Weight2 fields in each grade daily..
This is the ultimate format of the report i want to generate:

 

DATE

A

B

C

D

WGHT1

WGHT2

SUM

WGHT1

WGHT2

SUM

WGHT1

WGHT2

SUM

WGHT1

WGHT2

SUM

1/10/2011

20

19

39

24

20

44

0

0

0

0

0

0

2/10/2011

18

22

40

21

0

21

0

0

0

0

0

0

3/10/2011

0

0

0

0

0

0

20

25

45

0

0

0

4/10/2011

0

0

0

0

0

0

0

0

0

0

24

21

5/10/2011

22

0

22

0

18

18

0

0

0

21

0

21

6/10/2011

0

0

0

0

0

0

0

20

20

0

0

0






 
Please HELP!!

 

 

IP IP Logged
Prince
Newbie
Newbie
Avatar

Joined: 05 Oct 2011
Location: Kenya
Online Status: Offline
Posts: 4
Quote Prince Replybullet Posted: 13 Oct 2011 at 5:13am


Thanks for you guide Jones,not yet there though..

Grade name in table 2 and 3 is picked from table 1 as a using a FK..
Sum in the report should sum Weight1 and Weight2 fields in each grade daily..
This is the ultimate format of the report i want to generate:

 

DATE

A

B

C

D

WGHT1

WGHT2

SUM

WGHT1

WGHT2

SUM

WGHT1

WGHT2

SUM

WGHT1

WGHT2

SUM

1/10/2011

20

19

39

24

20

44

0

0

0

0

0

0

2/10/2011

18

22

40

21

0

21

0

0

0

0

0

0

3/10/2011

0

0

0

0

0

0

20

25

45

0

0

0

4/10/2011

0

0

0

0

0

0

0

0

0

0

24

21

5/10/2011

22

0

22

0

18

18

0

0

0

21

0

21

6/10/2011

0

0

0

0

0

0

0

20

20

0

0

0






 
Please HELP!!

 

 

IP IP Logged
Prince
Newbie
Newbie
Avatar

Joined: 05 Oct 2011
Location: Kenya
Online Status: Offline
Posts: 4
Quote Prince Replybullet Posted: 13 Oct 2011 at 5:20am

I have tried the formula but still am not getting the desired report, it duplicates values for the rows.
I have three tables with the following fieds:
TABLE 1:     
             

GRADEID

GRADENAME

1

A

2

B

3

C

4

D

                                                                      





TABLE 2:

DATE

GRADENAME_FK

WGHT1

1/10/2011

A

20          

2/10/2011

A

18

1/10/2011

B

24

1/10/2011

D

21

2/10/2011

B

21

3/10/2011

C

20

5/10/2011

A

22

5/10/2011

D

21













TABLE 3:

DATE

GRADENAME_FK

WGHT2

1/10/2011

A

19

1/10/2011

B

20

2/10/2011

A

22

3/10/2011

C

25

4/10/2011

A

21

4/10/2011

D

24

5/10/2011

B

18

6/10/2011

C

20









IP IP Logged
sgtjim
Newbie
Newbie
Avatar

Joined: 23 Aug 2011
Online Status: Offline
Posts: 32
Quote sgtjim Replybullet Posted: 13 Oct 2011 at 11:53am
I have run into this issue in the past. Crystal wants to display everything is row format, but you want things in be in a column format.

Sadly, crystal is a real pain if you try and deviate from this.

I got around it by developing the report in a SQL command object with sub queries, so that I then could display the report how I wanted to.

The SQL would look something like this.

SELECT
TABLE1.DATE,
TABLE2.DATE,
Weight_A.wieght_for_a

FROM

TABLE 1 tbl1

LEFT JOIN TABLE2 tbl2 ON tbl1.SOMEID= tbl2.SOMEID

LEFT JOIN

--here is the subquery

(SELECT
   tbl1_2.SOMEID
   tbl1_2.weight AS wieght_for_a
   FROM TABLE1 tbl1_2
   WHERE tbl_2.GRADE = A
   GROUP BY
   tbl1_2.SOMEID
   tbl1_2.weight
   ) Weight_A ON tbl1.SOMEID = tbl1_2.SOMEID

--you will need a sub-query for each grade, then you should be able to get the report to display how you want

WHERE

--Here is where you put your normal where statement

GROUP BY
TABLE1.DATE,
TABLE2.DATE,
Weight_A.wieght_for_a



Edited by sgtjim - 13 Oct 2011 at 12:00pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Oct 2011 at 12:29pm
another approach would be to mimic a crosstab (only if you do not have too many 'grad Names') .
Based on your tables you ill get a cartesian result after you join the 3 together. You can deal with this by
 
grouping on datefield set to per day
writing 2 Running Totals's per grade name, one for weight1 and one for weight2 (6 total in your sample data).
RT examples:
name=weight1 A
field to summarize=weight1
type=maximum
evaulate=use a formula
table2.gradename_fk='A"
reset=on change of group (date)
 
name=weight2A
field to summarize=weight2
type=maximum
evaulate=use a formula
table3.gradename_fk='A"
reset=on change of group (date)
 
now one formula per summary you want
//SUM_A
#weight1 + #weight2
 
repeat per gradename_fk
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Oct 2011 at 12:34pm
here is a sample of how you plae it in footers to mimic the crosstab (each row is a group footer)
 
 
A B
 
DATE WGHT1 WGHT2 SUM WGHT1 WGHT2 SUM
1/10/2011 weight1 A
weight2 a
SUM_A
weight1 B
weight2 B
SUM_B
2/10/2011
weight1 A
weight2 a
SUM_A
weight1 B
weight2 B
SUM_B
IP IP Logged
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