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 based on numeric field in BIRT reports
Priyadharshini MuniyandiJ
<div>Hi all,</div>
<div> </div>
<div>I'm new to BIRT Reports. Can you please share information on how to sort based on column of data type number </div>
<div>I could see only sorting done on String based columns</div>
<div> </div>
<div>TIA,</div>
<div>Priyadharshini </div>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>Where do you see that limitation? Can you give us an example of where it doesn't work? As well, please provide the version of BIRT you are using.</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>P.</p>
Priyadharshini MuniyandiJ
<div>Hi,</div>
<div> </div>
<div>My sincerest apologies for the delayed response.</div>
<div> </div>
<div>I'm trying to sort a resultset based on a column of type decimal</div>
<div> </div>
<div>Report table is configured with a joined data set</div>
<div>BIRT Framework :<span> </span>4.4.2</div>
<div>****************</div>
<div> </div>
<div>Data Source : Oracle</div>
<div>*************</div>
<div>Sorting Configuration</div>
<div>*********************</div>
<div>Property Editor of Table --> Sorting Tab, with the following values</div>
<div>Key : Decimal Column</div>
<div>Direction : Descending </div>
<div>Locale Auto</div>
<div>Strength : <<Have tried all option listed available>></div>
<div> </div>
<div>Can you please let me know how the result set can be sorted from the sorting tab configurations.</div>
<div> </div>
<div> </div>
<div> </div>
<div>TIA,</div>
<div>Priyadharshini</div>
pricher
<p>Hi,</p>
<p> </p>
<p>You should be able to sort on any data type. I have noticed that you have some scripting in the Report's beforeFactory method that adds the same sort key to the table; this code is superfluous.</p>
<p> </p>
<p>P.</p>
Priyadharshini MuniyandiJ
<p>Hi,</p>
<p> </p>
<p>Thanks for highlighting the unneeded script in the report template.</p>
<p>I tried configuring a sort key only on the Report table and still doesn't get sorted in the decreasing order of the sum.</p>
<p> </p>
<p>Does it got to do anything with the Joined Data Set defined for the table?</p>
<p>Can you please let me know how else can sorting be achieved ?</p>
<p> </p>
<p>TIA,</p>
<p>Priyadharshini Muniyandi.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>I am looking again at the report sample you sent earlier. I noticed that on the table SERVICE, you have a grouping on SERVICE_UDDI and the field you want to sort on, SERVICE_INVOCATIONS, is actually located in the group footer area of the table. Does that mean that you want to sort on the SUM of SERVICE_INVOCATIONS by SERVICE_UDDI? If so, you need to create a SUM aggregation of SERVICE_INVOCATIONS at the SERVICE_UDDI level, use that aggregation as a sort key at the group level (not the table level), and display the aggregation (not the data set field) in the group footer. The sorting actually looks like this:</p>
<p>
Priyadharshini MuniyandiJ
<p>Hi Pierre,</p>
<p> </p>
<p>Thank you so much for sharing the sample report.</p>
<p>Meanwhile, I was able to get the table sorted by adding the below javascript to the beforeFactory method.</p>
<p> </p>
<p>***************************************************************************************************************************</p>
<div>importPackage(Packages.org.eclipse.birt.report.model.api);</div>
<div>importPackage(Packages.org.eclipse.birt.report.model.api.elements);</div>
<div>importPackage(Packages.java.util);</div>
<div>importPackage(Packages.com.ibm.icu.util);</div>
<div>tbl = reportContext.getDesignHandle().findElement("SERVICE");</div>
<div>var lc = new ULocale(reportContext.getLocale());</div>
<div>sc = StructureFactory.createSortKey();</div>
<div>sc.setKey("dataSetRow[\"Service Invocations::SERVICE_INVOCATIONS\"]");</div>
<div>sc.setDirection("desc");</div>
<div>sc.setLocale(lc);</div>
<div>var tblGroup = tbl.getGroups().get(0);</div>
<div>ph = tblGroup.getPropertyHandle(TableHandle.SORT_PROP);</div>
<div>ph.addItem(sc);</div>
<div>************************************************************************************************************************************************************</div>
<p>I have attached the working copy to this post. Please let me know if this will cause any impact on the performance, like the time taken to generate to report.</p>
<p> </p>
<p>TIA,</p>
<p>Priyadharshini Muniyandi</p>
<p> </p>
<p> </p>
pricher
<p>Hi,</p>
<p> </p>
<p>I don't understand why you are writing script to perform something that is available through the UI... Unless you want to do something dynamic. Anyhow, this should have no impact on performance.</p>
<p> </p>
<p>P.</p>
srilekhach
<p>Hi,</p>
<p> </p>
<p> I am new to Birt Reports. How to perform dynamic sort on aggregated column. I followed the above report steps for static sorting.It worked. </p>
<p> </p>
<p>Thanks,</p>
<p>Sri</p>