Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Trying to perform a simple division between two computed columns
Memo
Hello everyone,
I am quite new to BIRT and not a programmer (I know, it spells nightmare).
I am trying to do a rather simple division, but fail miserably.
I have a single column flat data source where I need to calculate a certain ratio.
I created two computed columns: one of them counts the number of rows, the other one counts the rows that have a certain value. Now I am tryin to divide the result of one count by the result of the other, to no avail. Both computed columns are integers, but the result I get from the division is NaN.
I have tried the following (please ignore any typos, I have used the expression builder at the computer at work and now I am writing everything from home and from memory):
First alternative was
row["computed column A"]/row["computed column B"]
The second:
BirtMath.divide (row["computed column A"], row["computed column B"])
There were other, rather wild alternatives that I have tried but I am too embarrassed to post them here.
I believe the problem stems from the types not matching but I am at a loss as to cast the types properly.
I am using BIRT 2.3.
Please help
Best regards
Memo
Find more posts tagged with
Comments
johnw
Instead of doing the divide operation as a computed column, just drop a Data element into the footer of the table, and use your divide operation in the expression. I would also use the Aggregation component in your table rather than using computed columns, or just use one computed column with an expression like:
if row["valueRow"] == valueExpecting
{
1;
}
else
{
0;
}
and put a sum aggregation on THAT computed column divided by total row count.
Of course, there is probably a Aggregation that does this already.