Data Analytics | Uncategorized

Alteryx Tool Tip: The Multi-Row Tool

Have you ever added a formula tool to your Alteryx workflow and suddenly realized that your IF/THEN logic is starting to look more like a book and less like a logical function? Or maybe you really miss the ability to simply reference a prior row’s result within an Excel function? In either scenario, you might be asking yourself: “There has to be a better way to write this formula!?”

There’s good news! The Alteryx Multi-Row tool allows you to reference results in prior or subsequent rows across multiple columns! In today’s blog post, I’ll walk through how to use the Alteryx Multi-Row tool to calculate a conditional running total, as well as apply tiered discounts to sales charges. You could apply similar logic to tiered pricing or taxes due based on tiered tax brackets (ex: United States federal tax rates).

Prefer to watch the workflow build? Check out the how-to video here!

Want to follow along? Download the workflow here!

The first two steps in our workflow prep the data for use in the multi-row tool. We transposed the pricing tier data so that the tiers, the lower range, the upper range, and the rate each had their own column. Then we joined that information with the gross usage charge transactional data.

From here, we add our first multi-row tool. There are a few key components to the configuration window of the multi-row tool.

In the top section of the tool, you’ll see that you can choose to update an existing field or create a new field. For this tool, we’re going to create a new field and call it “Tier Running Total”. This will essentially be the running total of each tier level based on the tier’s lower/upper range and the actual usage charge. You also have the option to group your data. The group by function is optional and really depends on the function you’re writing and how your data is sorted going into the formula tool.

In the middle section of the configuration window, you’ll see variables that are available to use within the function calculation. The key here are the three groups:

  • Row -1: These reference the selected field from the prior row of data
  • Row +0 (Active Row): These reference the selected field from the current row of data
  • Row +1: These reference the selected field from the next row of data

Finally, the bottom section of the configuration pane is where you will actually write your function.

So let’s break down the function we use to create our running total:

  • Tier 1 – this tier serves two purposes:
    • Since we’ve sorted our data by customer name & tier, this indicates that we’ve started looking at charges for a new customer, so we don’t want to reference any prior rows (as those pertain to a different customer).
    • This is the base of all future calculations for a customer – tier one can either be the upper range of tier one OR it could be usage charge itself, if the usage charge is less than the upper range. We apply the MIN function to apply the minimum of those two results
  • Each subsequent tier:
    • As with any running total, we always want to reference the previous running total result – this is where we apply the Row-1 reference to the Tier Running Total field we’re creating.
    • Because we don’t want to reference a value that exceeds the upper range of the tier, we want to add either the minimum of:
      • The total usage charge less the prior row’s Tier Running Total field OR
      • The upper range of the tier

Once we run the workflow, you can see the results:

Next, we need to calculate the tier charge level. We’re going to use another multi-row tool for this so that we can reference the prior row running total we just calculated. To determine the actual tier charge level, we want to take the minimum result of either the current row’s running total less the prior row’s running total OR we want to take the upper limit of the tier. Again, this function prevents us from exceeding the upper limit of the tier.

Once we run the workflow, we can review the results:

While we could calculate the tiered usage charge as part of the multi-formula tool, I opted to do this in a standard formula tool so I could use the “Tier Charge Level” field as part of a data validation step. I’ve added a formula tool to calculate the tiered usage charge as well as the discount in dollars:

You’ll notice that while we have the info we need, the actual customer data is still blown out for each tier level. If we want to aggregate this into a summary view by customer, we can add a summarize tool to the canvas:

I’ve included both the gross usage charge (the single row item from our transactional data) and the tier charge level (the sum of each tier’s charge amount based on the tier range limits) – if everything is working as it should, these values should be exactly the same. Once the data has been summarized and the check has been added, the final result is a summary by customer of the gross usage charge, the total net usage charge, and the total discount:

The biggest benefit to using the Alteryx multi-row tool to perform this calculation is that it can be fully dynamic – as new tiers are added or as tiers are removed/consolidated, you won’t need to update any IF/THEN logic that specifically names tiers.

Alteryx is a powerful tool that can provide efficiency and scalability. I enjoy helping clients recognize value by finding better ways to automate their business data processes, then using the time savings to identify business value and insights in their data. To learn more about how I and Lovelytics help clients do more with their data, please visit us at https://lovelytics.com/or connect with us by email at [email protected].

Author

Related Posts

Feb 20 2025

Enterprise Forecasting Is Broken – Here’s How to Fix It

Imagine if annual, quarterly, and monthly forecasting were completely rethought. Imagine if they didn’t take up literally half of your team’s time. How many companies...
Jan 21 2025

What is Apache Spark and how does it work?

Apache Spark is a type of technology that uses distributed systems. In this article, we explain what it is, the key concepts to keep in mind, and provide guidance to...
Dec 04 2024

Demystifying Snowflake’s Open Catalog

Snowflake has recently rebranded (or at least repackaged) their managed Polaris offering as Snowflake Open Catalog. Let’s dig in and see exactly what this means...
Nov 26 2024

Data Engineering: How to Create a Test Plan

In this article, we explain how to create a minimal test plan in data engineering. We discuss the importance of ensuring process quality with a detailed and documented...
Nov 14 2024

Modern Data Architecture with AWS: How to Build It?

In this article, we explain how to build a modern data architecture with AWS. Additionally, we describe the ecosystem of services it offers for Data Analytics projects....
Nov 04 2024

Demand Forecasting Framework: A Nimble, Deep Learning Approach to Model Demand

Demand Planning is a complex discipline. What at first sounds like a relatively simple question — “how much do we need to order when?” — conceals a vast array of...
Oct 14 2024

The Problem with “Snowberg”

Using an open lakehouse architecture – one that stores data in a user’s own cloud storage accounts using an open source storage format (like Apache Iceberg) and data...
Sep 25 2024

What is a data lake?

In this article, we explain in detail what a data lake is, its advantages, and disadvantages. Additionally, we describe how these types of architectures are composed...
Apr 12 2024

The Highly Prized & Ever Elusive “Speed-to-Value”

We’ve all heard someone say “show value early and often” or “find quick wins”, but while seeking speed-to-value is a widely accepted principle, it is often an elusive...
Apr 12 2024

Time series Forecasting in Advanced Analytics

Introduction Time series is nothing but a sequence of values that are indexed in time order. That simple structure has made it very easy to collect in almost all...