Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Combining Multiple Rows/Records Post Reply Post New Topic
Author Message
tiadrop
Newbie
Newbie
Avatar

Joined: 04 Dec 2008
Location: United States
Online Status: Offline
Posts: 2
Quote tiadrop Replybullet Topic: Combining Multiple Rows/Records
     Posted: 04 Dec 2008 at 12:56pm

I have a report where one person has two records. One is the old record with the old job and the other is the new record with the new job.

 

I need a single line of data for this person, but I also need the old job for a calculation for the new job’s row.

 

Name               Job                               Quota   Actual $

John Doe          Sales Ex (new)             2000    100

John Doe          Sales Rep (old)            0          0

 

I need this to happen.  If John Doe’s old is Sales Rep and his new job is Sales Ex then multiple current Quota by 2.

 
Name               Job                   Quota   Actual $

John Doe          Sales Ex           2000    (100 * 2) = 200

 

I can't use previous or next record because the data comes out in a different order. There are about 15 job combinations resulting in different calculations. Please help me with this ANYBODY!! Confused



Edited by tiadrop - 05 Dec 2008 at 7:45am
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 08 Dec 2008 at 1:40am
Hi Tia,
 
Use the code below,I have tested  creating command object ,you can create a view or stored procedure in SQL
 
Select
New.Name,
New.Job,
Old.Job,
case when Old.Job = 'Sales Rep (old)' then
New.Actual * 2
end,
New.Quota,
New.Actual
from job New
left Join Job Old on New.Name = Old.Name AND old.Job = 'Sales Rep (old)'
 
The above Sql Joins the table to itself and calculates the actual in same row ...
 
This is the results  in two rows as new old ,but it also calculates the actual
Once the report is generated you can suppress the details section
checking for
 
{table.job} = 'Sales Rep (old) '
this will display one row with the calculations .
 
let me know if it works,or you can post some more sample data to playaround....
Cheers
Rahul
IP IP Logged
tiadrop
Newbie
Newbie
Avatar

Joined: 04 Dec 2008
Location: United States
Online Status: Offline
Posts: 2
Quote tiadrop Replybullet Posted: 08 Dec 2008 at 10:39am
Thanks for the response. This would be great, but the data is from an Excel document. I don't think I can create a view from Excel, right?
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 08 Dec 2008 at 1:23pm
Hi
 
Can you email me the excel sheet,I will try to get the desired results......
 
cheers
Rahul
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