Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula editor - simple question Post Reply Post New Topic
Author Message
kmham
Newbie
Newbie


Joined: 06 Mar 2007
Online Status: Offline
Posts: 2
Quote kmham Replybullet Topic: Formula editor - simple question
    Posted: 06 Mar 2007 at 9:34pm
How can I add 2 or more fields together in Crystal XI using the Formula Editor? I also need to know how to add a fixed amount to the total.

Currently, my Formula Field is called "Total Due" and in the formula editor it looks something like this:

{table.amount1} + {table.amount2} + {table.amount3} + 11.88

If I leave off the "fixed amount of 11.88", I get 3 amounts in my new field instead of the total amount. If I leave the fixed amount of 11.88 in the formula, I get an error message saying that a string is required here.

I'm sure this is easy if someone know the proper syntax.

Thanks in advance for any help - it's greatly appreciated!!!
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Mar 2007 at 2:05am
The amount fields appear to be strings instead of numbers (better check your database). That's why it concatenates them together instead of adding them together. You need to convert the strings to numbers.

CDbl({table.amount1}) + CDbl({table.amount2}) + CDbl({table.amount3}) + 11.88
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
kmham
Newbie
Newbie


Joined: 06 Mar 2007
Online Status: Offline
Posts: 2
Quote kmham Replybullet Posted: 07 Mar 2007 at 5:55am

Brian,

I wasn't sure what CDbl does so I tried "tonumber" ...

tonumber({table.amount1}) + tonumber({table.amount3})  + tonumber({table.amount3}) + 11.88
 
And this fixed the problem.  Apparently the data is string as you mentioned.
IP IP Logged
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.000 seconds.