Articles in this section
Category / Section

How to Apply Aggregate Functions on String Columns in Grid Widget

Published:

How to Apply Aggregate Functions on String Columns in Grid Widget

This article explains why aggregate functions cannot be directly applied to string columns in the grid widget and provide an alternative method to achieve similar functionality using expressions. Please note that aggregate functions, such as SUM or AVG, are designed for numeric data and are not applicable to string values.

Why Aggregate Functions Are Not Available for String Columns?

Aggregate functions are intended for performing mathematical operations on numeric data. Since strings are not numerical in nature, aggregate functions like SUM or AVG cannot be applied directly to string columns in the grid widget. The grid widget in this context supports sorting and filtering functionalities for string columns but not aggregate functions.

Using Expressions to Achieve Aggregation on String Columns:

Although direct aggregation is not possible for string columns in the grid widget, you can utilize expressions to achieve similar results. Follow the steps below to create an expression that performs aggregation on a string field and displays the results in the grid widget.

  1. Identify the string field for which you want to calculate aggregation, such as CustomerID.
  2. Construct an expression using aggregate functions like COUNT and DISTINCT COUNT along with the string field.
  3. Bind the expression to the grid widget.

Example Expression:
Here’s an example expression that calculates the COUNT and DISTINCT COUNT of the CustomerID string field:

  1. COUNT([CustomerID]) - Calculates the total count of CustomerID values.
  2. DISTINCT COUNT([CustomerID]) - Calculates the count of unique CustomerID values.

By binding this expression to the grid widget, you can display the calculated counts for the CustomerID string field.

rte_image_102.jpeg

Additional References

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
NM
Written by Nihal Mohamed Ali
Updated
Comments (0)
Please  to leave a comment
Access denied
Access denied