/    /  Amazon QuickSight – avg

Amazon QuickSight – avg

 

The avg function in Amazon QuickSight is an aggregate function that calculates the average (mean) of a set of decimal values.It takes one or more decimal expressions as input and returns the average of those values. 

You can also optionally group the data by one or more dimensions using the group-by parameter.

Syntax

#Start#
avg(decimal-expression[, group-by-level])
#End#

 

This function takes two arguments

  1. decimal-expression: A decimal expression that represents the data you want to calculate the average for. You can use column names, constants, or other expressions as inputs.
  2. group-by-leve: An optional parameter that allows you to group the data by one or more dimensions. You can use column names, constants, or other expressions as inputs.

 

Suppose you have a dataset that contains information about the sales of a company in different regions. 

The dataset has the following columns:

  • Region: The name of the region where the sales were made.
  • Sales: The total sales for each region.

To calculate the average sales for each region, you could use the following expression:

Example

#Start#
avg({Sales}, [{Region}])
#End#

 

This expression calculates the average of the Sales column, grouped by the Region column. The result would be a table showing each region’s average sales.

For example, if the dataset contains the following data:

RegionSales
East100
East200
West150
West300

 

The result of the expression would be a table that shows the following values

Regionavg(Sales)
East150
West225

This means that the average sales for the East region are $150, and the average sales for the West region are $225.