X
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

Oct 10 2023

Bet on Data: Navigating the Future of iGaming and Sports Betting

A look at the role key trends in customer experience, product innovation, and business growth have in shaping the sports betting and iGaming industry’s...
Abr 13 2023

The Databricks lakehouse TKOs the competition on TCO

Whether you look at hard dollars alone or add other factors, the Databricks lakehouse remains the most strategic investment.

Mar 20 2023

Introducing Gamehouse: A Lovelytics Game Analytics Brickbuilder Solution

Quickly stand up a 360-degree view of your game using Lovelytics’ game analytics Brickbuilder Solution

Ene 17 2023

Data lake + data warehouse = lakehouse: Modernize your data warehouse to a lakehouse

The View from the Lakehouse Blog Series PART 2 Over the past few years, the term “data lakehouse” has grown in popularity. Why?  Fundamentally, a data lakehouse...
Nov 30 2022

Why we bet our business on Databricks, and why you should too

The View from the Lakehouse Blog Series PART 1 Recently, Lovelytics held our first in-person all-hands meeting in more than a year. We gathered at our headquarters in...
Nov 23 2022

Three reasons why I’m thankful to be a part of the Lovelytics team

Most of us are inevitably going to be asked one of the most common questions this time of year: “What are you thankful for?”  Of course, I am grateful for my...
Oct 30 2022

Alteryx Tool Tip: Don’t Fear the Blob

Using the Blob Tools to Output Data into Formatted Excel Templates While “the Blob” might sound like a cheesy horror movie or an unidentified substance you scrape off...
Oct 22 2022

Web Scraping With the Modern Data Stack

I’ve always found web scraping interesting, there’s a massive trove of data available to us in a wide array of formats- it presents the perfect ‘big data’ problem, how...
Oct 10 2022

Performing Ad-Hoc Analysis and developing agile dashboards in Databricks SQL

Synopsis: This article is a 101 level introduction to Databricks SQL, and will walk you through the steps to build simple visualizations directly within a Lakehouse...
Oct 04 2022

How to compare a Static Dimensional Value to a Dynamic Value of the same Dimension-Part 2

Welcome to Part 2 of the series comparing one “static” dimensional value against another “dynamic” value of the same dimension. In this section, we are going to focus...