# Adding a Percentage Comparison Formula in Crystal Reports

Hi

I am very new to Crystal Reports especially when it comes to adding numerous different formulas and conditions.
I have a report I have made which works in everyway it should including most formula except the percentage ones.  I need to find the percentage difference from 2 values.  I have created4 if, then else formula and 2 sum formula to add relevant values to gether.  These are fine.  My database contains no numerical values only string text and dates.  I created If, then else formula to add different statuses together and sum to add each of these together.  I need to create a percentage formula to caluclat edifference between the 2 SUM values but this is not working.  I tried insert summary and selecting option for percentage difference but this only gave me option to pick one field which is not the one I need.

Any ideas or pointing me in right direction

Many Thanks
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
well to find the % diff, it is a simple formula.
A = 0
B = 2

if isnull(A) or A= 0 then 0
else (A/B)*100

A and B represent your fields.
0
Commented:
That is a percentage not a difference.

I think you really need

(A-B)/B

mlmcc
0
Commented:
Opps.. yeah you are right.. but my head was in the right direction.. hehehe.
0
Commented:
Also you should check if B is 0 to avoid a 0 divide error

mlmcc
0
Author Commented:
Hi

Thanks for comments.  I am almost there but as per you comment mlmcc I do have nil values for field b.  creating the if function ho wdo i incorporate the second field b = 0 into the formula

Thanks
0
Commented:
Somethin glike

If B = 0 then
0
else
(A-B)/B

mlmcc
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB Reporting Tools

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.