SUMMARIZE
Last updated
Was this helpful?
Last updated
Was this helpful?
Aggregates the values in a metric by its aggregation summary type (sum, average or formula) for the specified dimensions.
In simple terms, the function takes a metric name, and zero or more dimension names as optional parameters, then returns the summary across those requested dimensions. It removes all other dimensions while computing the summary.
Syntax: SUMMARIZE (
metric_or_variable
,
dimension1
,
dimension2,...
)
metric_or_variable
is the name of the metric or variable
dimension1
, dimension2
, ... (optional) are the dimension names you want to aggregate the values by
For example, consider the Revenue
metric for the period of Jul '23 to Sep '23.
The Revenue metric contains three nested dimensions — Region, Country and Territory. The dimension values for Region are APAC, Europe and North America. Each Region has Countries and each Country has Territories.
Example to calculate the Revenue by country:
Let's create a new metric Revenue by Country
and use the summarize function to compute the values.
Revenue by Country = SUMMARIZE ( Revenue, Country )
Output:
Example to calculate the Revenue share of a country to the overall revenue:
Create a new metric Revenue Share - Country to Overall Revenue
.
Revenue Share - Country to Overall Revenue = Revenue of a Country / Total Revenue of Business
For example, Canada's share of the Revenue is $1,050 / $12,800 = 8.2%
, France's revenue share is $1,800 / $12,800 = 14.06%
and so on.
To get the Revenue of a Country in the numerator, we first add Country as a dimension to this new metric.
Since we want the Total Revenue in the denominator, we don't need to specify any dimension and the summarize function will aggregate values across all dimensions.
Revenue Share - Country to Overall Revenue = Revenue / SUMMARIZE ( Revenue )
Output:
Example to calculate the Revenue share of a country to its region:
Create a new metric Revenue Share - Country to Region
.
Revenue Share - Country to Region = Revenue of a Country / Total Revenue of Region
For example, Canada's share of the Revenue to its Region is $1,050 / $6,600 = 15.91%
, France's revenue share is $1,800 / $4,000 = 45%
and so on.
To get the the Revenue of a Country in the numerator, we first add Country as a dimension to this new metric.
Since we want the Revenue of a Region in the denominator, we summarize using the dimension Region.
Revenue Share - Country to Region = Revenue / SUMMARIZE ( Revenue, Region )
Output:
Related function: