Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: formula error Post Reply Post New Topic
Author Message
rockville9
Newbie
Newbie
Avatar

Joined: 24 Sep 2014
Online Status: Offline
Posts: 2
Quote rockville9 Replybullet Topic: formula error
     Posted: 24 Sep 2014 at 7:55am
Hi. I pretty much know very little about programming in Crystal. Just enough to get a few pre-written reports to look how I want them. Add data fields, format, that's about it.

I am trying to get our invoices to subtract a "unit discount", and display a "net extended" on the item line. I was able to write the code to make the subtraction just fine. The problem I'm having is on the report, if other items ordered by a customer do not have a discount, the "net extended" field on this item line is blank.

Another issue is the "total" on the invoice only calculates the line that has a "unit discount", most likely because the line that does not have a disc has no line total. Does this make sense?

The data section I'm working in is a "detail" section.

The "unit price" is the data field "ord_dtl.prcby_prc".

The "extended" field originally was @totprdamt, and the formula was simply, round({ord_dtl.totprdamt},2), which i mean to round off the result to 2 decimal places

The formula i substituted is as follows:
round(({ord_dtl.totprdamt})-(({ord_ddl.oi_rat})*{ord_dtl.shpqty}),2)

ord_ddl.oi_rate = the amount off per unit of measure
ord_dtl.shpqty = units shipped on the order

as i stated, this formula will correctly display a "net extended" but will result in a blank field if there is no discount applied. I have no idea how to move forward...

thanks!
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 24 Sep 2014 at 10:11pm
In the formula editor change the setting "Exceptions for Nulls" to "Default Values for Nulls"
 
this will then set the discount to 0 when not set, therefore
amt - (0*qty)
IP IP Logged
rockville9
Newbie
Newbie
Avatar

Joined: 24 Sep 2014
Online Status: Offline
Posts: 2
Quote rockville9 Replybullet Posted: 26 Sep 2014 at 7:54am
wow. z9962, thanks. works perfectly now!!!
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