Use case
This component can be used to analyze data by aggregating values from a single dataset in different categories. For example, you can use it to:- Calculate total sales per product using a dataset containing data from multiple individual sales.
- Monitor average product downtime per day using a dataset containing downtime data for multiple products over a longer period of time.
Properties
A human-readable name for the component.
Select which aggregate function to call to combine the grouped values from the Pivot Column. For more information, read the following:
Specify the column from the source table or sub-query that will be aggregated. This requires an input component before configuring and uses the column names from the input component.The data type expected in this column depends on the aggregate function you are depending to use. For example, you cannot average non-numeric values.
Specify the column from the source table or sub-query that contains the values that will group data for aggregations and from which new column names will be generated. This requires an input component before configuring and uses the column names from the input component.The chosen Value Column will be missing from the output, replaced by a new column for each of the Pivot Values specified.
A list of values that exist in the Value Column in the input data that are used to group data for aggregation. These values become new columns in the output, with data from the Pivot Column being aggregated into these new columns.
Choose whether to enclose the new column names (the selected pivot values) in quote marks. This can avoid problems with the component if your pivot values contain spaces or special characters, if your pivot values are numeric data, or if your data is in mixed case.If you use Snowflake, we recommend selecting
Yes because Snowflake has specific rules for column identifiers. Enclosing your pivot values in quotes helps to meet these rules.Examples
- Example 1
- Example 2
Goal: Calculate total monthly sales for each productWe have the following table, containing data from individual sales of three different products (caps, T-shirts, and hoodies) in January, February, and March. Let’s use the Pivot component to group the sales data by month and calculate the total sales for each month.Input data
Component configuration
Result: The pivot values
| Product | Month | Sales |
|---|---|---|
| T-Shirt | Jan | 100 |
| T-Shirt | Jan | 50 |
| T-Shirt | Feb | 150 |
| T-Shirt | Mar | 200 |
| Hoodie | Jan | 200 |
| Hoodie | Jan | 100 |
| Hoodie | Mar | 250 |
| Hoodie | Mar | 180 |
| Cap | Jan | 60 |
| Cap | Feb | 90 |
| Cap | Mar | 120 |
- Aggregate Function: Sum
- Pivot Column: Month
- Value Column: Sales
- Pivot Values: Jan, Feb, Mar
| Product | Jan | Feb | Mar |
|---|---|---|---|
| T-Shirt | 150 | 150 | 200 |
| Hoodie | 300 | 430 | |
| Cap | 60 | 90 | 120 |
Jan, Feb, and Mar are used as the new column names. The values in the value column Sales are aggregated using the Sum function and grouped by the values in the pivot column Month. There was no sales data for hoodies in February, so this value is null.
