Aggregation function that returns the sum of the values in a column.


sum(double[] exp, groupBy)
  • double[] exp : expression evaluating to double
  • groupBy : optional grouping function


    double representing the sum of the values in the column. If groupBy is used, sum returns the sum for each group.


Consider the following table of example data:

Year    Quarter    Month    Amount Sold

2019    Q1         M1       100
2019    Q1         M2       200
2019    Q1         M3       100
2019    Q2         M4       150
2019    Q2         M5       250
2019    Q2         M6       150
2019    Q3         M7       200
2019    Q3         M8       250 
2019    Q3         M9       300 
2019    Q4         M10      100 
2019    Q4         M11      50 
2019    Q4         M12      50
2020    Q1         M1       150
2020    Q1         M2       100
2020    Q1         M3       200
2020    Q2         M4       150
2020    Q2         M5       100
2020    Q2         M6       150
2020    Q3         M7       50
2020    Q3         M8       100 
2020    Q3         M9       200 
2020    Q4         M10      150 
2020    Q4         M11      100 
2020    Q4         M12      50

Find the total amount sold (add up the values in the Amount Sold column).


Find the total amount sold for each quarter for each year.

SUM(Amount Sold, group by (Year, Quarter))

Use the following steps for detailed instructions on how to use the groupBy parameter:


The data has been uploaded, then added and loaded into a Schema named Sales_Acme. For information on creating a data source and a schema, refer to the Guides→Start document.

  • In the Navigation bar, select the Content tab, and then select + New → Add Dashboard.
  • In the Add Dashboard dialog, for Name, enter Sales Dashboard, and then select Add.
  • In the Action bar, select + (add icon).
  • In the Insight panel, select Listing Table or V.
  • In Tables, select Aggregated Table.
  • In the Data panel, select Add Data Set (+).
  • In the Manage Data Sets panel, select Sales_Acme.
  • From the Data panel, drag and drop the following fields to the Grouping Dimension tray:

    • Year
    • Quarter
    • Month
  • Drag and drop the Amount Sold column to the Measure tray.
  • From the Data panel, drag and drop Add Formula to the Measure tray.
  • The Formula Builder automatically opens:

    • In Search Functions, select the down arrow, and then select Aggregation Functions.
    • Double-click sum(double[] exp, groupBy) to add the formula to the editor.
    • In the Formula Editor, replace double[] exp with Amount_Sold and dimension, … with Year,Quarter from the Data panel.

    • Select Validate & Save.
  • In the Measure tray, double-click the New Formula pill and rename it to Amount Sold Per Quarter.
  • In the Action bar, select Save.

For more information, refer to the Level Based Measure document.

© Incorta, Inc. All Rights Reserved.