Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export division by 0

Status
Not open for further replies.

Charlessm

Technical User
Aug 3, 2009
8
US
I have a formula that helps with my division by 0 issue. Whenever I preview the report with data, everything comes out just fine. But when I try to export the report to excel, the division by 0 message pops up with the formula workshop. Is there something I'm missing? I am by no means an expert at crystal reports, any assistance would be appreciated.
 
Check your formulas.

If you have {field1} / {fieldb}

replace with
if {fieldb}=0 then 0 else
{field1} / {fieldb}

that should remvoe any divide by zero errors. I suspect the error is on a subsequence page. Preview only shows the first page while Export processes all pages.
 
Hi crystalkiwibruce. Thanks for your reply. As I mentioned below, I already have a formula. I've copied below.

whileprintingrecords;
if {@Gross Profit} <>0 then
{@Gross Profit}/Sum ({@Sales}, {LineItem.ItemID}) *-100
else 0

When I hit View > Print Preview, I can see all records and data. But when I try to export to excel, I'll get the division by 0 error message. I originally input the formula when I got the message when trying to Print Preview. I'll need another way to fix this. Thanks.
 
Checking that {@Gross Profit} is non zero will not avoid the divide by zero error. You should check to see if Sum ({@Sales}, {LineItem.ItemID}) is zero.

whileprintingrecords;
if Sum ({@Sales}, {LineItem.ItemID} <>0 then
{@Gross Profit}/Sum ({@Sales}, {LineItem.ItemID}) *-100
else 0
 
Kray4660,

Worked perfectly! I'm still pretty new to this, a great learning experience. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top