Using the Multi-Field Formula tool in Alteryx

Whilst using Alteryx to restructure data, there may be times where you want to apply a formula across multiple columns simultaneously. Luckily for us, the software has a tool that handles this and below is a short example showing how we can apply this to save time when prepping.

Data before applying the Multi-Field Formula tool

For this demonstration, we'll be rounding each of the 'X Drug Price' columns to 2 decimal places and then multiplying them by 'AK Chance'; the logic for this can be seen in the 'Expression' box in the bottom left of the interface. Instead of going through and writing out a formula for every target column, we can tick them all in the 'Select x fields' section at the top and then use the generic '_CurrentFields_' measure to represent each of them in the formula. In this instance, we want to replace the original column and so haven't selected 'Copy Output Fields and Add' - if we were to do this then we would get a bunch of new columns at the end of our data set named 'New_X Drug Price', with the transformation applied.

Data set after applying the Multi-Field Formula tool

Within the image above, you can see the data set after applying the MFF tool. The reason the values are not to 2 decimal places, as the expression suggests, is because they have each been multiplied by the 'AK Chance' following the rounding step. If we were to leave out this final part of the formula then we would get the results shown below.

Drug Prices to 2 decimal places

Although this example has only shown rounding and multiplication, we can apply any function we want to columns of a similar nature. A list of these can be found within 'Functions' and then navigating to whichever you need. If required for the formula then we can also bring in measures from the 'Original Fields' dropdown, just like we did for 'AK Chance'. Finally, the data type of the output field can also be changed by ticking the 'Change Output Type to' box and then selecting the desired option.

Selecting the rounding function from the 'Math' folder
Bringing a measure into the formula from the 'Original Fields' menu
Author:
Nathan Purvis
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab