Adding and removing measures
To add a measure to the cross tab, use Crosstab.addMeasure( ). The addMeasure( ) function accepts an actuate.xtabanalyzer.Measure object as a parameter. This example creates a new measure and adds it to a cross tab:
var measure = new actuate.xtabanalyzer.Measure( );
 
measure.setIndex(1);
measure.setMeasureName("Quarter Rate");
measure.setExpression("[revenue]/[revenue_SalesDate/year_Product/PRODUCTLINE]");
crosstab.addMeasure(measure);
crosstab.submit( );
The measure.setExpression( ) function dynamically sets the measure to display the revenue received for sales data, organized by year and product line. In this example, the expression is in easyscript. Easyscript is described in Using Actuate BIRT Designer Professional. The expression in the example is the database field that contains the sales revenue value. Data Analyzer aggregates the sales revenue value for each year for each product line. The [revenue_SalesDate/year_Product
/PRODUCTLINE] string specifies that the expression applies to the revenue by salesdate and then by year for the product line.
The Actuate JavaScript API combined with standard JavaScript functionality enables the creation of web pages that allow for interactive manipulation of cross tabs. In this example, the measure name and the measure expression are retrieved from HTML elements with the names of measureName and measureExpression. As coded, these elements can be an item such as a text entry field. The values of any used elements then go into the new measure for the cross tab.
var measureName = document.getElementById("measureName").value;
var measureExpression = document.getElementById("measureExpression").value;
 
var measure = new actuate.xtabanalyzer.Measure( );
measure.setIndex(1);
measure.setMeasureName(measureName);
measure.setExpression(measureExpression);
 
crosstab.addMeasure(measure);
crosstab.submit( );
The web page must contain elements with the IDs of measureName and measureExpression. Use the following HTML code to create these elements:
<INPUT TYPE="text" SIZE="60" ID="measureName" VALUE="Quarter Rate">
<INPUT type="text" SIZE="60" ID="measureExpression" VALUE="[revenue]/[revenue_SalesDate/year_Product/PRODUCTLINE]">
Use removeMeasure( ) to remove a measure. Pass the name of the measure to remove to removeMeasure( ).
crosstab.removeMeasure("Quarter Rate");
crosstab.submit( );

Additional Links:

Copyright Actuate Corporation 2012