This recipe shows how you can remove extra column in cube by using Java code.
- Create a report template (DynamicCube.rml) using the given datasource (FruitSales.ds).
- Define the following parameter in the “Report > Parameters” page:Name = RemoveColumn, Value = ${Remove Column#choice(Yes,No)#No}
- Add a cube into the report template. Add the coding into “Cube Properties > Scripts > On Render Begin”:if (“Yes”==Parameters.get(“RemoveColumn”))
{ var count = getMeasureCount();
if (count>1) // only remove if more than one measure present
removeMeasure(getMeasure(count-1));
}
Screenshot of selecting “No”:
Screenshot of selecting “Yes”:
To download the necessary files for this recipe, refer to the attached ZIP package.
HowToRemoveColumnInCube.zip (3.6 KB)