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)
Sorting Logic
KapsHere
Hi All,
I am designing BIRT reports for my project. The reports use scripted data source.
The BIRT environment details are as follows:
Business Intelligence and Reporting Tools
Version: 2.3.0.v200804251-7N7Y-AYdeIEKS6mGZPHGhs-0vEl6
Build id: v20080618-0630
BIRT Report Designer
Version: 2.3.0.v20080431-7X7n-ECLmlsLx_z-4z0LEaYz-mA8
Build id: v20080618-0630
BIRT Report Runtime
Version: 2.3.0.v20080516-7g890ELRXmproz-xIDPOJ1
Build id: v20080618-0630
The Problem:
I need to sort my BIRT reports based on the data in one column. The data in the column can be in one of the following formats:
1) a - b (range format): where both 'a' and 'b' are numeric values(integers or floats), with or without space around the dash('-') symbol.
2) a: where 'a' is an integer or a String
Following are valid examples of the data:
1, Null, Excl999, 54 - 99, 2000-4000, aaaa
In both the above cases i need to use 'a' as the sort key. For the same i have written some logic in javascript. The logic works fine for range format, but something goes wrong with it at run time, when i have data which is not in range format and has both numeric and alphanumeric values. e.g. 55, 40, abcd30
To simulate the above scenario, i have created a test BIRT report using sample DB. Please find it attached. I am using a computed column to get the data which has both numbers and strings. The sorting tab for the table has the sorting logic.
When i preview this report, it shows the results some times and at other times it gives the following error:
"Fail to compute value from sort, group or filter expression. Can not convert the value of NV to Double type."
You might need to preview the report 4-5 times to get the error as i am using Math.random() function to get random numbers.
Please let me know the reason and solution for this issue, taking into consideration the requirements i have.
Regards,
Kapil
Find more posts tagged with
Comments
KapsHere
It seems if i remove all the 'returns' keywords from the customSort() function, there is no exception at run time. But now it doesnt sort the numeric ranges properly!!
It sorts the numeric ranges as Strings. e.g. when the range column has values 22-50, 4-8, it displays them in the following order:
22-50
4-8
can somebody tell me why??
KapsHere
Got it!
in the sorting logic > customSort() method in the attached report, comment all returns statements that return something in case of a String.
dont exactly understand why BIRT allows it to work now!
Thanks,
Kapil
mkh
<p>Hi <span><span>Kaps,</span></span></p><p> </p><p><span><span>I do have the same query,</span></span></p><p> </p><p><span><span>As i am getting a column from from the query which is of type ''String''.</span></span></p><p> </p><p> </p><p><span><span>as i am using birt 4.2 version.</span></span></p><p> </p><p><span><span>for example:</span></span></p><p> </p><p><span><span>values like:</span></span></p><p> </p><p><span><span>123</span></span></p><p><span><span>1</span></span></p><p><span><span>2</span></span></p><p><span><span>3</span></span></p><p> </p><p><span><span>a1</span></span></p><p><span><span>a2</span></span></p><p><span><span>a3</span></span></p><p><span><span>a10</span></span></p><p> </p><p> </p><p><span><span>abc</span></span></p><p><span><span>acs</span></span></p><p><span><span>ade</span></span></p><p><span><span>axd</span></span></p><p> </p><p> </p><p><span><span>these are three types of string format values which are comming from Database.</span></span></p><p> </p><p><span><span>As the requirement is to display first numbers,then alpha numberic and then strings in ascending order.</span></span></p><p> </p><p> </p><p><span><span>like </span></span></p><p> </p><p><span><span>1</span></span></p><p><span><span>2</span></span></p><p><span><span>3</span></span></p><p><span><span>1a</span></span></p><p><span><span>a2</span></span></p><p> </p><p> </p><p><span><span>apple,</span></span></p><p><span><span>boy</span></span></p><p><span><span>call</span></span></p><p> </p><p> </p><p><span><span>please suggest me about how to get the values sorted.</span></span></p>