sisense.com
✅ You are viewing documentation for the latest version of Compose SDK.
Version:

Function contribution

contribution(measure, name?): CalculatedMeasure

Creates a calculated contribution measure.

A contribution measure calculates the contribution, in percentage, of a measure towards the total. Percentages are expressed as a number between 0 and 1 (e.g. 42% is 0.42).

For example, using the Sample Ecommerce data model you can retrieve the total cost of products categorized by age range. Using a contribution measure you can calculate how much each age range's total cost contributes to the total cost across all age ranges. So, the total cost for the 35-44 age range is 23.64M, which is 22% of the 107.27M of all age ranges together. Therefore, the contribution of the 35-44 age range is .22.

Parameters

ParameterTypeDescription
measureMeasureMeasure to apply the Contribution logic to
name?stringName for the new measure

Returns

CalculatedMeasure

A calculated measure instance

Example

Calculates the percentage of the total cost across all categories for items in a category from the Sample Ecommerce data model.

measureFactory.contribution(measureFactory.sum(DM.Commerce.Cost))

Contribution values from the Sample Ecommerce data model when categorizing by age range.

AgeRangeCostContribution
0-184.32M0.04
19-248.66M0.08
25-3421.19M0.2
35-4423.64M0.22
45-5420.39M0.19
55-6411.82M0.11
65+17.26M0.16
Last Updated: