सामग्री पर जाएँ

लेसन 17 · Formulas and Summaries

Summarize and Running Totals

Group and aggregate data with the Alteryx Summarize tool, build running totals and shares of total, count distinct values and verify results with controls.

Most analysis ends in a summary: sales by region, orders per customer, average time per ticket. The Summarize tool in the Transform category does this work, much like SQL GROUP BY.

This lesson covers grouping, running totals, shares and the checks that keep totals honest.

How Summarize works

You add fields and choose an action for each one. The most common actions:

Action Result
Group By One output row per distinct combination
Sum, Average, Min, Max, Median Numeric statistics
Count Number of records
Count Distinct Number of different values
Concatenate Joins text values into one string
First, Last The first or last value in the group's order

The exact list depends on the field type and your version. First and Last depend on order, so sort before using them.

If you configure no Group By, the output is a single row that summarizes everything.

SQL Stand-in: group by, count, distinct count and sum

Press Run (or Ctrl + Enter) to see the result here.

Look at South: there are two records but only one amount, and the average is based on that one value. In every tool, check how nulls are counted. Your question might be "average per order" or "average of known amounts", and the two differ.

Concatenate

Concatenate is useful for making lists, such as all product codes per order. Choose a separator, and check the size of the output field so long lists are not cut off. Sort first if the order of items in the list matters.

Weighted averages

A plain average of averages is usually wrong. If one store sold 2 items at a price of 10 and another sold 98 items at 20, the average price is not 15. Compute total revenue divided by total units. The Weighted Average tool, or a Summarize followed by a Formula, does this.

Python Stand-in: average of averages versus weighted average

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Running totals

The Running Total tool adds a cumulative sum to each row. You choose the field to total and optional grouping fields, so the sum restarts per group. As with Multi-Row Formula, the order matters: sort by group and date first.

SQL Stand-in: running total and share of total

Press Run (or Ctrl + Enter) to see the result here.

In Alteryx, a share of total is often built as: Summarize to get totals per group, Join that result back to the detail rows on the group field, then divide in a Formula. For a grand total without groups, use Append Fields.

flowchart LR
  A["Detail rows"] --> S["Summarize<br/>total per store"]
  A --> J["Join on store"]
  S --> J
  J --> F["Formula<br/>sales / total"]

Aggregate on a branch, then join the totals back to the detail.

Control totals

Build a habit of checking:

  1. The grand total after aggregation equals the total before it.
  2. The sum of counts per group equals the input record count.
  3. Group values you did not expect (blank or misspelled categories) are visible.

A second Summarize without Group By makes these comparisons quick. If totals differ, look for a filter, a join that multiplied rows or a null group.

Python Stand-in: reconcile before and after

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last line shows how silently removing the blank group changes the total.

Choosing the grouping

The grouping fields define the meaning of each output row. Before you configure the tool, finish this sentence: "I want one row per ...". If the answer is "region and month", then those two fields are Group By and everything else is either aggregated or dropped.

A column that is neither grouped nor aggregated does not appear in the output. This surprises people who expect a customer name to stay next to the customer ID. Either group by both, if each ID has exactly one name, or join the name back after the summary. If you group by both and an ID has two spellings of the name, you get two rows for that ID, which is a useful sign of a data quality problem.

Be careful with percentages that are already in the detail data. Adding them or averaging them rarely has a sensible meaning. Summarize the numerator and the denominator separately, and calculate the percentage afterward.

Empty groups

A summary shows only groups that exist in the input. A store without sales is simply absent, which readers may not notice. If every store must appear, start from the full list of stores, join the summary to it and union the unmatched stores back with a total of zero. Decide whether zero is truthful: "no sales" and "file not received" look the same unless you check for them separately.

Practice task

Create twelve invented sales rows with a store, a month, a customer and an amount. Include one missing amount, one blank store and a customer who buys more than once.

By hand, work out the records, distinct customers and total for one store. Then summarize and compare. Add a second summary without Group By and confirm that the grand total equals the sum of the group totals, including the blank group. Finally, create a running total per store, and check that its last value in each store equals that store's total.

Common mistakes

Do not summarize after a join without first checking for duplicated rows. A multiplied row is counted more than once.

  • Averaging percentages or averages without weights.
  • Using First or Last on unsorted data.
  • Forgetting to rename the output fields, such as Sum_amount.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What does a Group By action create?

    Rows are collapsed per distinct group.
  2. 2. Why can an average of store averages mislead?

    A weighted average accounts for the size of each group.
  3. 3. What should you do before using Running Total?

    The cumulative sum follows the current row order.
  4. 4. How can you compute each row's share of its group total?

    The joined total gives every detail row its denominator.

Summary

  • Summarize groups rows and applies actions like Sum and Count Distinct.
  • Check how nulls are counted and use weighted averages where needed.
  • Running Total needs correct order and grouping.
  • Reconcile totals and counts before you trust a summary.

Next: Building Standard Macros

आपकी प्रगति इसी ब्राउज़र में सेव होती है। खाते की ज़रूरत नहीं है।