In Tableau, the use of aggregate functions enables you to either summarize or alter the level of detail in your data. When building a calculation, you cannot combine an aggregated value and a disaggregated value.
As noted, common aggregate functions will be discussed in this blog. However, there are many more aggregate functions that are used in Tableau. A complete list can be found when “Aggregate” is chosen in “Create Calculated Field.”
Aggregate functions can also be applied by dragging a pill (via right click) into the rows or columns shelves. When dropped on to the shelf, an aggregate function can be chosen from the list that is displayed.
MIN / MAX
When using the MIN and MAX aggregate functions, the minimum and maximum values will be returned. Though these aggregate functions are best known for being used with numerical data types, they can also be used with dates and strings.
Dates
When using MIN and MAX aggregate functions with dates, MIN will return the first date while MAX will return the most recent date.
Strings
When using MIN and MAX aggregate functions with strings, MIN and MAX will return values based on alphabetical order. MIN will return the first string while MAX will return the last string.
SUM
When using the SUM function, it returns the total of all values, though null values are ignored. This aggregate function can be used only with numeric data types. It is common to see this with aggregate function automatically populate with measures (e.g., Discount, Profit, Quantity, Sales) when dragged to the rows or columns shelves. Below is the Sales from the Sample-Superstore data set.
AVG
When using the average function, it returns the average of all values, though null values are ignored. Similar to SUM, this aggregate function can be used only with numeric data types.
COUNT / COUNTD
When using the COUNT function to count the number of items in the Product Name field from the Sample-Superstore data set, all the items in the field are counted. Therefore, if a particular product has 10 items in stock, all 10 items are counted. Below is an example of the count of all the items in stock (per product name) in the Sample-Superstore data set.
When using the COUNTD, each distinct product is counted. In this case, a particular product is only counted once, regardless of the number of items in stock. Below is an example of the count of all distinct count of product names in the Sample-Superstore data set.