Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Loop/Iterative/Batch Macro that takes in all records where <condition = TRUE>

abovino
7 - Meteor

Hello Gurus,

 

This is a problem I've come across several times in the past but I've never been able to solve (always found a work around somehow) but I'm throwing in the towel and asking for help this time.

 

How can I create a macro that will take in all records where a given condition is met.  For example, given this data set:

 

CompanySale
ACME156
Company & Co678
ACME78
ACME1865
Company & Co235

 

How can my macro:

 

  1. Take in all records where [Company] == "ACME"
  2. Perform calculations X, Y, and Z
  3. Create a file containing ONLY [Company] data (This part I know how to do)
  4. THEN, take in all records where Company == "Company & Co"
  5. Repeat steps 2 & 3
  6. Continue for each unique [Company] name in the table

So essentially, loop over an undetermined number of [Company] names, and perform calculations X, Y, Z for each

4 REPLIES 4
LordNeilLord
15 - Aurora

Hey @abovino

 

My question is....why do you need a macro to do this?

 

Most of the tools in Alteryx have the ability to group and work with the data at a company level

 

@LordNeilLord

Part time Tableau, Part Time Alteryx. Full Time Awesome


Data Lover

abovino
7 - Meteor

Hi @LordNeilLord, thanks for the response.

 

The catch here is that my outputs are CSV files that contain excel formulas which are driven by the recordID (As seen here), and I need a separate file for each customer.

 

So my original solution was:

 

  1. Use the formula tool to create a column with the absolute path and name of the file using the customer name (IE: "C:\absolute\path\" + [customer_name] + ".csv")
  2. Output tool uses, "Take File/Table Name From Field" feature

Great! I have a file for each customer and all my excel formulas are in place ... Or so I thought.  Here is my Alteryx formula to compose an Excel formula:

 

  • "=J" + [RecordID] + "*" + [PRICE-1]  (Which when opened in Excel will appear as the following formula, "=J2*32.99"

So this method works fine for the first file that's created but the subsequent files still maintain the Alteryx RecordID in my composed formula.  This will be the formula in the first row of the 2nd CSV file:

 

  • "=J32*28.99" but what I really need is "=J2*28.99"

I don't necessarily need to use a macro to solve this, but perhaps I've been looking at this problem for so long I have tunnel vision.

LordNeilLord
15 - Aurora

Hey @abovino

 

I understand!

 

Ok, so yeah a batch macro could do the job but it maybe easier to use a multirow formula tool instead. In the attached example I am outputting a spreadsheet per "Category" so in the mutirow I have used the "group by" function to restart at every category.

 

Formulas.PNG

 

@LordNeilLord

Part time Tableau, Part Time Alteryx. Full Time Awesome


Data Lover

abovino
7 - Meteor

This worked perfect. I didn't realize you can group by fields using the multi-row formula tool.  Thanks!

Labels