On January 27, 2021, Google is changing the required permissions for attaching IAM roles to service accounts. If you are using IAM roles for your Google service accounts, please see Changes to User Management.
You can apply aggregate functions to groups of values in one or more columns to generate aggregated data. Depending on how you configure the Group By transformation, the output of these transformations is a new table or one or more columns in the current dataset.
- The Group By transformation does not support nested expressions. You cannot insert multiple nested expressions in your computed value.
- The Group By transformation supports aggregation functions only. For more information, see Aggregate Functions.
The following table contains test score data from a set of students for four separate tests, spread over two days:
Aggregating across all rows (no grouping)
You can perform basic computations across all rows of the dataset. For example, the following transformation creates a new column containing the average test score for all students:
|Parameter: Formula type||
|Parameter: New column name||
The above results in a new column called,
average_TestScore, containing the single value
85.19, which is the average of all students' test scores rounded to two decimal places.
NOTE: These types of aggregations are known as flat aggregations. In larger datasets, performing flat aggregations can be computationally intensive. Be careful in computing any aggregation functions across a large number of rows.
Aggregate grouped-by rows
For the above example data, suppose you are interested in the average score for each student. In this case, you must compute the average (
AVERAGE(TestScore)) for each student.
In the previous transformation, you used the New Formula transformation. When you are computing aggregations across groups of values in a column, you must use the Group By transformation:
|Parameter: Group By||
Note that the above transformation does not contain the rounding function. Nested expressions are not supported in the Group By transformation. To round the values, add the following transformation as the next step:
You may wish to rename the newly generated column to something like
average_TestScorePerStudent instead. See Rename Columns.
The output data should look like the following:
Generate new aggregation table
Suppose you wish to calculate the minimum, maximum, and average scores for each test. In this case, it may be more useful to create a new table in which the student names have been removed:
|Parameter: Group By||
The resulting data looks like the following:
Tip: In this case, when you replace the existing table with a completely new table, data that is not included in the aggregation is lost. You can add columns to the list of values if you wish to bring forward untouched columns into the new table. You may also consider building aggregation tables in a recipe that is extended from the previous recipe, so that you can continue to work with the other columns in your dataset.
This page has no comments.