Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Urgent Report Help to calculate a difference in me Post Reply Post New Topic
Author Message
Inieas
Newbie
Newbie


Joined: 25 May 2011
Online Status: Offline
Posts: 6
Quote Inieas Replybullet Topic: Urgent Report Help to calculate a difference in me
     Posted: 25 May 2011 at 6:38am
 I am a complete newby to Crystal Reports and need help with the following please:

    I have the following info in a table called "tblMeters" i am working with:

    PDate - Date of the meter
    AssetNo - The machine Number
    SoftMeter In - The meter for the machine

    I managed to do the following to allow the user to select the 2 dates he need the info for:
    In formulas I specified:
    {@start date} CDate Minimum ({tblMeters.PDate)

    and

    {@end date} CDate Maximum ({tblMeters.PDate)

    I then Created a Parameter field Called "Select Date"

    I then Created a record selection of:
    {tblMeters.PDate} = {?Select Date}

    I now manage to get the report to display the following:

    AssetNo MeterIn

    I need to do the following:

    Subtract the MeterIn for {@start date} from the MeterIn for {@end date}

    example:

    Dates chosen:

    start date = 24.03.2011
    end date = 27.03.2011

    Machine Number = 53TX

    MeterIn for 24.03.2011 is 1000
    MeterIn for 27.03.2011 is 5000

    So the report should show me:

    Machine Number Meter Difference
    53XT 4000


    Please help me do this!!!!!!!!
I hate struggling so bad!!!!!
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 26 May 2011 at 5:59am
In formulas I specified:    {@start date} CDate Minimum ({tblMeters.PDate) and  {@end date} CDate Maximum ({tblMeters.PDate)
 
is this formula being used to get the min and max so you can subtract one from the other?
 
create 2  formulas
if date = start date then {meter field amount} else 0
 
if date =end date then {meter field amount} else 0
it should pick up the value for the min and max dates for the specific machine (make sure you group by asset#)
 
then create a formula that subtracts the 2 formulas created above.
sharona
IP IP Logged
Inieas
Newbie
Newbie


Joined: 25 May 2011
Online Status: Offline
Posts: 6
Quote Inieas Replybullet Posted: 27 May 2011 at 3:12am
Hi again, and again Thanks for the help, but I am so lost and confused right now.

Lets say the person choses from 05/24/2011 to 05/25/2011

What I am trying to achieve is the following:

Code:
Machine Number          Difference
53TX                          4000 (Meters From 25/05/2011 minus meters from 24/05/2011)
54XT                          1000 (Meters From 25/05/2011 minus meters from 24/05/2011)
What I am getting when I chose the 2 dates is:

Code:
Machine Number               Formula 1     Formula 2
53TX                           5000           0
53TX                           1000           0
54TX                           2000           0
54TX                           1000           0
and when I pull the report again without changing any date selection is:

Code:
Machine Number               Formula 1       Formula 2
53TX                           1000             0
53TX                           5000             0
54TX                           1000             0
54TX                           2000             0
Where it actually swaps the info for some reason.

Like I said i am so lost and confused right now!
I hate struggling so bad!!!!!
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 27 May 2011 at 3:32am

lets start from the beginning

place your fields in the details section

create a group for machine id
it should group all the details records by that id
 
create a formula by machine id
min(date) and max(date)
place them in the details.
this should just display the min date and max date (if there are other dates this formula should be blank)
 
this is just for testing purposes: create a formula
if date(thats in the detail section) =min date then 1
if date(thats in the detail section) =max date then 2
 
it should flag the records you want to see
 
then go to the record supression and conditionally surpress the
not(flag formula ) in (1,2)
(you cant group by a min or max formula)
 
if that displays your correct information then
create 2 formula that states
if flag =1 then meter amt
if flag =2 then meter amt
 
this should grab the meter value at the min max date
 
if this is all working so far( i hope so)
then create a final formula
amt1-amt2 or vice verse
 
hope this helps.
 
sharona
IP IP Logged
Inieas
Newbie
Newbie


Joined: 25 May 2011
Online Status: Offline
Posts: 6
Quote Inieas Replybullet Posted: 27 May 2011 at 6:19am
I have done as your previous message, but now get every meter from the databse.

I give up, burn crystal and hire a programmer?
I hate struggling so bad!!!!!
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