Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Compare Data in 2 different rows Post Reply Post New Topic
Author Message
thummel1
Senior Member
Senior Member
Avatar

Joined: 27 Apr 2012
Location: United States
Online Status: Offline
Posts: 140
Quote thummel1 Replybullet Topic: Compare Data in 2 different rows
     Posted: 19 Dec 2013 at 3:07am
I'm using Crystal 2008. The goal of the report is to display records for both Federal and State W4 exemptions IF one of the two deductions (or both)have been modified within the last 7 days. If both deduction were modified later than 7 days, then exclude. This is my first challenge. My second step is to display only records where the State exemption is less than the Fed. I think I can figure that out. My raw data looks like this (I've added the last 2 columns to illustrate the records I'll need to capture:
Employee Deduction Code Date Stamp Scenario Result
1234 9FDW 9/1/2012 1 Display on the report
1235 9MNW 12/19/2013 1 Display on the report
5555 9FDW 12/19/2013 2 Display on the report
5555 9MNW 12/19/2013 2 Display on the report
4444 9FDW 9/1/2012 3 Do not Display
4444 9MNW 9/1/2012 3 Do No Display
 
Once I've captured the first 2 scenarios, then I will move to grouping by Employee and doing running totals to align the Exemptions (not shown) so they can be compared.
"Press any key to continue. Where's the 'Any' Key?" ~Homer Simpson
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Dec 2013 at 4:56am
I would think that a stored procedure would be 'easier' but barring that, I think what I would try is something along the lines of this:
in the main report I would generate a list of employees or some identifier for all the records that have been modified in the last 7 days. I would stored these values in a shared array variable.

Then I would have a subreport, that would be the 'actual' report and I would pass the shared array variable and filter those records to be both records assigned to the value in the array...

I would write the stored proc to do a similar process...fist find records that were modified in the time period and then return all records associated with the changed records, and then display them.

Hopefully, this makes sense as a strategy to get the report up and running.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Dec 2013 at 4:56am
if you can't do the store proc you can also consider group criteria and do a group select statement.
group on the employee
create a flag formula
if datediff('d',dtable.datestamp,currentdate)<=7 then 1
sum this at the group level
now any group with a sum of flag >0 is an amplyee you want to see
use that in the group select statement
sum(flag,employee)>0


Edited by DBlank - 20 Dec 2013 at 5:04am
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