Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calculated field based in above record

Posted on 2009-04-23
8
Medium Priority
?
282 Views
Last Modified: 2012-05-06
Hi,
Ive got a field in my report, TOTAL, and next to it I want to add another field based in the amount in TOTAL - the amont in TOTAL from the record just above.

Like this:

TOTAL     TOTAL2
----------------------
2                 --
3                  1        ---> from 3 (current record) - 2 ( record above)
2                 -1        ---> 2 (current TOTAL) - 3 (TOTAL previous record)

is this possible?
0
Comment
Question by:arcross
  • 3
  • 2
  • 2
7 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 24216490
Crreate a formula like this

If OnFirstRecord then
   0
else
   {YourField} - Previous({YourField})

If you really need the first one to display -- then use

If OnFirstRecord then
   '--'
else
   ToText({YourField} - Previous({YourField}),0,'')

mlmcc

0
 
LVL 8

Author Comment

by:arcross
ID: 24222903
hey mlmcc that works spot on ! but now ive been asked by the customer they need to add something else in the calculation.
So i need to pass a parameter to the crystal report with this new value and divide it by the result of the formula you showed me.

llike:

NEW VALUE / {myfield} - Previous {MyField}

The only thing this, sometimes, can result in divided by 0 error. So I need to display some text instead.
thanks!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24225756
Try this

If {myfield} - Previous {MyField} = 0 then
    0
else
    NEW VALUE / {myfield} - Previous {MyField}

mlmcc
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
LVL 101

Expert Comment

by:mlmcc
ID: 24225771
If you need to show it as a string then

If {myfield} - Previous {MyField} = 0 then
    '--'
else
    ToText(NEW VALUE / {myfield} - Previous {MyField},2,'')

mlmcc
0
 
LVL 35

Assisted Solution

by:James0628
James0628 earned 1000 total points
ID: 24230576
If you need to divide the parameter by the result of the original calculation, you need to use ():

  {?parameter} / ({myfield} - Previous ({MyField}))


 Without the (), it will divide {?parameter} by {myfield} and then subtract Previous ({MyField}) from the result.

 James
0
 
LVL 35

Expert Comment

by:James0628
ID: 24240468
mlmcc should get at least most of the credit here.  He provided your solution.  Twice.  I just made a small adjustment to his second solution.

 James
0
 
LVL 8

Author Comment

by:arcross
ID: 24240789
Yes he should. I meant to accept his and give assisted answer to yours. For some reason my browser went funny and it didnt  do it.
How do i do it?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Screencast - Getting to Know the Pipeline
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question