Introduction

This tutorial is a continuation on the previous post on the three types of macros in Alteryx. Here we will focus on the first type – the standard macro. To recap, a standard macro in Alteryx allows you to encapsulate workflows into reusable components to improve efficiency, remove redundancy, and allow for standardisation.

In this tutorial, we will create a standard macro that calculates the engagement ratio (likes + dislikes per view) for different categories of YouTube videos.

Step 1: Load the Dataset

Download the dataset from this link and import the youtube_2005.csv file using the Input Data tool.

The file contains the following seven columns:

  1. Rank: the ranking within the top 1000.
  2. Video: the videos title.
  3. Video views: how many views the video received.
  4. Likes: how many likes the video received.
  5. Dislikes: how many dislikes the video received (2021 and prior).
  6. Category: the category of the video.
  7. Published: the year the video was published.

Step 2: Select the Fields and Convert Data Types

Use the Data Cleansing tool to remove the punctuation from the Video views, Likes, and Dislikes columns.

For this macro we will use the Category, Video views, Likes, Dislikes and Published columns.

Use the select tool to select the previously mentioned fields. Additionally, change the datatypes for Video views, Likes, and Dislikes to Double.

Step 3: Calculate Engagement Ratio for each Category

Use the Summarize tool to group by Category and sum the Likes, Dislikes, Video Views, and take the min of Year.

Use the Formula tool to create a new field called “Engagement Ratio”. The calculation will be:

([Likes] + [Dislikes]) / [Video views]

Optionally, sort the Engagement Ratio field to see the best performers using the sort tool. The workflow should look similar to the following.

Step 4: Convert to Macro

To convert this workflow into a standard macro right-click on the Input Data tool and select Convert To Macro Input.

Do the same for the Browse tool.

If these steps were successful, you will see the Workflow Configuration Type automatically changes to a Standard Macro.

Save the newly created Standard Macro as EngagementRatio.yxmc.

Step 5: Use the Macro in a New Workflow

Open a new workflow and import the youtube_2021.csv file using the Import Data tool.

Now right-click on the canvas and select Insert –> Macro and then select the newly created EngagementMacro.

Add a Browse Tool to the output anchor of the macro.

Run the workflow and discover which category had the highest engagement ratio in 2021.

Conclusion

In this tutorial we worked through the process of creating a standard macro in Alteryx. Additionally, we used the macro in a new workflow to test its functionality. In the next post we work through the process of creating and using batch macros.

Troy
Author: Troy

Troy holds degrees in Science, IT, and Education. These have equipped him with a multidisciplinary foundation combining analytical thinking, problem-solving, and technical proficiency. During his graduate studies at CSIRO, where he analysed genetic sequence data and gene expression profiles as part of a broader research project, he developed a deep interest in uncovering insights through data. After several years as a STEM educator, Troy has transitioned back to being data-focused, bringing a unique perspective shaped by his teaching experience and ability to convey complex ideas effectively. His skills cover the entire data lifecycle, from data cleaning and analysis to creating effective visualisations that support decision-making. In his free time, Troy enjoys trail running and staying active, relishing the chance to clear his mind and explore the outdoors.