[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.birt] Re: Computed Columns -- how to prevent divide by zero errors

Outstanding!

Der Spunk rules.

morangatang


Der Spunk wrote:
Try:
if (row["f"]==0) {0} else {row["f"]/row["e"]}


"morangatang" <morangatang@xxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag news:e1ocn7$b91$1@xxxxxxxxxxxxxxxxxxxx
I'm loving BIRT and I have found a *lot* of great information in this newsgroup, however this week I have been struggling with computed columns and divide by zero errors.

Let's say I have columns a, b, c, and d.

I want to display a column equal to (a-b)/(c-d)

(c-d) is occasionally equal to zero, exposing me to divide-by-zero errors at runtime.

I created computed columns called e = (a-b) and f = (c-d)

I have attempted a bunch of times to create a computed column called g that conditionally calculates (e / f) if f != 0 but I'm getting killed with all kinds of errors -- javascript formatting, ; missing before , etc.

Here are some of the ways I tried to make computed column g so far:


(row["f"] = 0) ? 0 : row["e"]/row["f"]


<VALUE-OF>(row["f"] = 0) ? 0 : row["e"]/row["f"]</VALUE-OF>


if row["f"] = 0 0; else row["e"]/row["f"];


Am I missing something simple here? Should I abandon computed columns and do this another way?


I'm using the Callisto M5 build
SDK Version: 3.2.0
Build id: I20060223-1656
BIRT 2.1.0.M20060303-0920

Anybody who helps is goin' on my Xmas list!