Print Page | Close Window

Division by zero in CrossTab

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=11398
Printed Date: 05 May 2024 at 2:14pm


Topic: Division by zero in CrossTab
Posted By: Megan10e
Subject: Division by zero in CrossTab
Date Posted: 12 Oct 2010 at 8:29am
I'm trying to do a calculated member in a cross tab report, to show the difference in percentage from one year to the next. Some of the values are zero, though, and Crystal won't run the calculation when there is division by zero.
 
How can I edit this formula to take care of that? Here is the formula Crystal comes up with when I try to do my calculated member:
 
//The calculation formula is used in place of the summaries in Calculated Members.
// This calculation formula must return a/an Number value.
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jan 2009"), CurrentSummaryIndex) / GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jan 2008"), CurrentSummaryIndex)
 
Thank you!



Replies:
Posted By: rvink
Date Posted: 12 Oct 2010 at 1:14pm
How about this:

if GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jan 2008"), CurrentSummaryIndex) = 0 then
  0
else
  GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jan 2009"), CurrentSummaryIndex) / GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Jan 2008"), CurrentSummaryIndex)
 




Print Page | Close Window