Product picker aggregates
Summarize
Summary of Product Picker Aggregates
Product picker aggregates enhance data analysis by enabling calculations such as sums, counts, and averages directly from selected products in a product picker. They streamline decision-making processes by allowing users to easily identify key metrics, like the product with the least demand volume.
Show less
Key Features
- Aggregate Functions: Includes Sum, Count, Min, Max, and Average for analyzing selected products.
- UI Configuration: Easily set up aggregates within the product picker UI by selecting fields and defining aggregate types.
- Admin API Configuration: Create and manage aggregates programmatically via API calls for advanced users.
Key Outcomes
By utilizing product picker aggregates, customers can efficiently calculate and summarize important data points, enhancing their ability to make informed decisions based on real-time product metrics. For instance, using the Max aggregate on a quantity field allows users to determine which product has the highest quantity selected, while the Sum aggregate provides the total quantity of selected products.
Aggregates help calculate and summarize data in products. Learn how to use aggregates in a product picker.
Product pickers let users select products from a list. Aggregates help calculate and summarize data (like sums, counts, or averages) from the selected products.
Product picker aggregates allow data collection and calculation for specific fields in a product picker. This helps analyze data directly from the product picker options.
Suppose you have a product picker containing various measurable products, and you need to identify which product has the least volume in demand. By applying a "Min" aggregate on the volume field, the smallest value is automatically determined, streamlining the decision process without needing a rule.
Available aggregate functions
| Aggregate Type | Behavior |
|---|---|
| Sum |
Sum of the base field values for each selected option, if they can be coerced to a number Does not multiply by the option quantity |
| Count | Count of options selected in a product picker |
| Min | Minimum of the base field values of the selected options, if they can be coerced to a number |
| Max | Maximum of the base field values of the selected options, if they can be coerced to a number |
| Average | Average of the base field values of the selected options, if they can be coerced to a number |
Aggregates can be configured through the UI configuration or by using admin APIs.
Configuring aggregates through the UI
To configure an aggregate through the UI, go to any product picker, and then on its definition page, click Option Fields. Then, in the Aggregate Fields section, click + Add.
When you create a new aggregate, provide the following details:
- Base Field: A list of available subfields of the product picker is displayed here. Select the sub-field to create a new aggregate.
- Aggregate Type: Select the aggregate type whose behavior fits your use case: Sum, Average, Min, Max, or Count.
- Aggregate Field Name: After defining the aggregate, its value is stored in a separate field to facilitate data display. This field is typically located beneath the product picker. The field's name clearly indicates that it represents an aggregate, ensuring easy interpretation. This is auto-generated by the system.
- Variable Name: This is the variable name of the aggregate field name that is created. The variable name is usually used to reference the product picker aggregates in scripting. This is auto-generated by the system.
- Delete: Use this icon only if you want to delete the added aggregate or if you want to remove any existing aggregates.
Configuring aggregates through the admin APIs
For steps to create and configure an aggregate using API calls, see Adding a product picker aggregate using APIs.
Viewing a product picker aggregate
Aggregate fields can be added to the layout and will automatically be calculated on the change of a field. Just as we can search a normal field by its display name or variable name and add it to the layout, we can do the same with the product picker aggregate. We search the aggregate field name or variable name of the newly created field, define the position in the layout by adding it under the product picker field for ease of display, and save the layout. To read more about the layout editor, see Layout editor.
The product picker field “Simple SM Prod Picker“ has many subfields. On the Subfield “Quantity“, we have added three aggregates: Max, Sum, and Count.
Products with different quantities
Suppose product A has a quantity of 1, and product B has a quantity of 3.
- Applying Max aggregate on quantity gives the value of aggregate field name “Quantity Max” as 3, as product a has the maximum quantity among the selected products.
- Applying Sum aggregate on quantity gives the value of aggregate field name “Quantity Sum” as 4, as product a quantity + product b quantity has value 4.
- Applying Count aggregate on quantity gives the value of aggregate field name “Select Count” as 2, as there are only 2 selected products among the list.