Skip to main content
Measures define the calculations performed on cube data. All measures are defined as CopperMeasure objects. There are two approaches:
  1. Copper API for simple measures
  2. Measure factories for parameterized or reusable patterns

Prerequisites

Before creating measures, make sure:
  • A cube is created (see configure cubes)
  • Copper API basics for measure definitions are understood

How to add a measure

The starting point for creating measures is the IMeasuresConfigurator interface from the cube configurator. There are two main approaches:
  1. IMeasuresConfigurator.addMeasure(String, CopperMeasure) - Add a measure defined with Copper API
  2. IMeasuresConfigurator.addMeasure(String, IMeasureFactoryInput, IMetadataConfigurer) - Add a measure using a factory

How to add a measure with Copper

Create measures directly with the Copper API for simple calculations:
The measure name is provided as the first argument of addMeasure; the methods copperMeasure.as("name") and copperMeasure.withName("name") are not supported. Intermediate measures that depend on each other must each be added separately via addMeasure.

How to use measure factories?

For complex scenarios, use a measure factory. This approach is useful when:
  • Measure creation requires parameterization
  • The Python API needs to modify elements used to create the measure
First, define the factory input class:
Then, implement the measure factory:
Finally, add the measure in the cube configuration:

How to register a custom measure factory

Measure factories can be registered in two ways. Static registration uses the @AtotiPluginValue annotation. The factory is discovered by the Registry:
Dynamic registration uses MeasureFactoryRegistration beans. Use this approach when the factory needs access to external objects, such as Spring-managed beans:
The factory does not need the @AtotiPluginValue annotation when using dynamic registration. Multiple factories can be registered in a single MeasureFactoryRegistration bean.

How to create aggregated measures

Use CopperNext to define aggregated measures and user-defined aggregation functions (UDAFs).
CopperNext is a temporary class to expose API related to Copper and the Atoti Configuration API. This class will be merged into Copper once the Atoti Configuration API is no longer experimental.
Reference the aggregated field with a FieldPath relative to a table:
Other available methods in CopperNext:
  • avg - Average aggregation
  • min - Minimum aggregation
  • max - Maximum aggregation
  • agg - Custom aggregation functions

How to create a UDAF

Use CopperNext.userDefinedAgg for user-defined aggregation functions:
The fluent API for UDAFs will be added in a future release.

How to rename measures

Predefined cubes may include measures that can be renamed. Add ‘name overrides’ in the application configuration file:
This configuration renames Measure1 to MeasureA and Measure with spaces to MeasureB. Use square brackets for measure names containing spaces.