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)
How to Add Aggregation using Design API
grather
<p>My last post about displaying the report parameter showed how much I needed help.</p>
<p>I thank those who answered.</p>
<p> </p>
<p>No on to my next help question.</p>
<p> </p>
<p>I want to add an aggregation (SUM) of a column using the Design API</p>
<p> </p>
<p>How do I do this.</p>
<p> </p>
<p>I think I need a computed column but can't quite figure it out.</p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
Clement Wong
<p>See the <em>beforeFactory </em>event in the attached design.</p>
<pre class="_prettyXprint _lang-">
importPackage( Packages.org.eclipse.birt.report.model.api );
var design= reportContext.getReportRunnable().designHandle.getDesignHandle();
var elementFactory = design.getElementFactory();
var table = design.findElement("myTable");
var aggrCC = StructureFactory.createComputedColumn();
aggrCC.setName("AVE_MSRP");
aggrCC.setAggregateFunction("AVE");
//If you have a group
//aggrCC.addAggregateOn("Product Code Group");
aggrCC.setDataType("Decimal");
aggrCC.setExpression("row[\"MSRP\"]");
table.getColumnBindings().addItem(aggrCC);
</pre>
grather
<p>Clement</p>
<p> </p>
<p>Again thank you so very much.</p>
<p>I almost had it.</p>
<p> </p>
<p>I had the Creating of the ComputedColumn. But what I was missing was adding it to the column binding then using that as a newDataItem.</p>
<p> </p>
<p>Again thank you so much for the help.</p>
<p> </p>
<p>Gary Rather</p>