Adding New Cube Measures

This page provides a description of how we can add a measure. The techniques employed are generic examples that can be extended, adapted, and repeated for any use case that we need. In all cases, we make minimal changes to the Reference Implementation.

Step 1 - Modify the schema selection

Modify the Cube’s schema so that the Field can be found and set to be a hierarchy. In this case, our modifications will be made in the createBASelection() method or createSASchemaSelectionDescription() method for the BA or SA Cube, respectively. The snippet is from the BA Cube’s Selection config.


Make sure that any new field added to the selection does not exist in the selection ready, and that it points to a corresponding field in a datastore.

ISelectionDescriptionBuilder.HasAllFields hasSomeFields = StartBuilding.selection(dsSchemaDesc.asDatabaseSchema())


        // Adding the TestField to selection
        .usingReference("BaseStore to TestFieldStore") // Reference from the Base Store to our new field's store
        .except("AsOfDate", "TradeId"); // Exclude fields that are found in other stores. The application will not start if the selection has duplicate fields unintentionally.

Step 2 - Define measure

In this case, we need to extend the BAMeasureBuilder class for creating measures.

public class ExtendedBAMeasureBuilder implements BAMeasureBuilder {

    public void measures(ICopperContext context) {
        return Copper.sum("TestField");

To read more about creating measures with Copper, see Creating and publishing measures.

Step 3 - Application config

Navigate to the configuration class where the original MeasureBuilder class (BAMeasureBuilder) was used. In this case,, and replace the old MeasureBuilder class with the newly extended one.


public ICanBuildCubeDescription<IActivePivotInstanceDescription> configureCubeBuilder(
    final INamedCubeDescriptionBuilder builder) {
        return builder
        - .withMeasures(BAMeasureBuilder::measures)
        + .withMeasures(ExtendedBAMeasureBuilder::measures) // Reference the Extended measure builder