Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: retrieving old field from report Post Reply Post New Topic
Page  of 2 Next >>
Author Message
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Topic: retrieving old field from report
    Posted: 06 Sep 2013 at 7:11am
Hello all!

I have a report that is evaluating employee rates from a date driven table. Each rate has an effective start date and a rate end date. My report is based off a start date and an end date that the user will supply to the report before running and what I'm trying to do (and failing miserably) is:

If an employee received a rate change show the date of the change and show the new salary. That part is easy enough and works perfectly however, the client would also like to see the difference between the new salary and old salary.

to get the new salary I'm able to use :
If {Rate.startDate} IN {@YYYStartDate} TO {@YYYEndDate} Then
    {@Salary}

and to get the old salary I'm using:
If {Rate.endDate} IN {@YYYStartDate} TO {@YYYEndDate} Then
    {@Salary}

to be as clear as i can the YYYStartDate and YYYEndDate are supplied from the user and Salary is a basic math formula taking the rate * pay frequency * number of pays in a year

If there is anything that maybe I'm doing wrong or if anyone has any ideas I'd love to hear them as I have tried everything that I can to get the old rate to figure the old salary. If i pull the SQL data from the report i can see that the old rate is there and for whatever reason not coming through to my report.

Thank you in advance.


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Sep 2013 at 7:22am
so you haev one table with possible multiple rows per employee. columns as  
employeeid
startdate (day rate went into effect)
end date (day rate endded and null for current rate)
rate
 
you user can enter a date range (begin and end date)
you need to retrieve all clients with all rates that were effective at anypoint during that range and show the annual salary?
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 06 Sep 2013 at 7:32am
basically.

rate.startdate(day rate started)
rate.enddate(08/24/2013) unless the rate is still active then it shows as rate.enddate(12/31/2100)

what i need to show is if the employee got a raise i need to show his name, the startdate of the new rate, the new salary and the difference between old and new salary

so....

employee: john smith
rate.startdate: 08/01/2013
rate: 10.00
rate.startdate: 08/24/2013
rate: 12.00
rate.enddate: 08/23/2013
rate.enddate: 12/31/2100

this would need to show like this
name         | new rate date | salary      | difference
john.smith | 08/24/2013     | 24960.00 | 4160.00

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Sep 2013 at 7:34am
what if they got more than one raise during the date range?
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 06 Sep 2013 at 7:40am
well, luckily when looking throught he database no one has yet.....although i'd wanna do a cya and make sure that I am able to see that as well providing that they all fall in during the dates provided.

this report would really only ever run on a 30 day window so i doubt that someone would get several raises in that time but it;s possible.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Sep 2013 at 8:08am

if someone does please send me a link to your HR services.

 
I assume your record select is something like
(rate.startdate<?enddate and rate.enddate>?startdate)
 
group on employee (concantenate the name with an ID to get a unique record per employee but still alpha per your preference)
I assume you have a PK from your table
do a distinct count on it at the employee level
do a group select to look for that value>1 to remove all of the employees with only one record
e.g. distinctcount(pk,employee)>1
hide your details and group header
in the group footer place the fields you want
name         | new rate date | salary      | difference
john.smith | 08/24/2013     | 24960.00 | 4160.00
 
 
name (and ID if needed) = the name field
new rate date = maximum(startdate,employee)
salary = maximum(rate,employee)*workdaysvalue
difference = (maximum(rate,employee)- minimum(rate,employee)) *workdaysvalue
 
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 06 Sep 2013 at 8:12am
yeah, that's pretty much how my report is already. the only thing I'm trying to not use max or min because some of the employees who got a pay change actually stepped down in pay. so max would pull the wrong data for rate. 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Sep 2013 at 8:19am
Maybe I dont want that link to the HR department...
maybe this..?
create a formula called RateCalc
if rate.startdate=(maximum(rate.start,rate.employee) then rate.rate else
if rate.startdate=(minimum(rate.start,rate.employee) then rate.rate *(-1)else 0
difference  SUM(@rateCalc, rate.employee) * workdaysvalue
Would also show negative amounts for step downs
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 06 Sep 2013 at 8:31am
ill give this a try and see what i come up with.

i'm not sure what you meant by link to hr department. did i miss something heh.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Sep 2013 at 8:34am
I wanted their phone number (link) if you had a bunch of employees pop up on your report with more than one raise in a 30 day period. but now that it could be more than one demotion i am rethinking my request.
Good luck with the report.
IP IP Logged
Page  of 2 Next >>
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.