Alteryx designer Discussions

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

Generate Number of Rows Based Off Value in Another Column

Highlighted
Meteor

As the title suggests, I want to copy the data from one row 4 times if the value in one column is API, and 2 times if the value is MX Loader. I've tried using the Generate Rows Tool, but keep running into errors such as: "Invalid type in operator==." and "The value did not change after the Loop Expression"

 

I'm fairly new with this tool and tried adding a condition expression of "

if contains([MX Loader/API],"API")
then + 4
elseif Contains([MX Loader/API], "MX Loader")
then + 2
else Null()
endif "

 

If anyone has any solutions, it would be greatly appreciated.

Highlighted
Alteryx Partner

HI @Julcas 

 

I have created a workflow for you (attached below) using generate rows.

 

My suggestion (and this caught me out) is to check the field type of the ColumnsToAdd field because it was a string for me, but generate rows needed an integer to compare it to.

 

Hope this helps you. Let me know if you have other queries.

 

- Andrew

Highlighted
Meteor

That worked! Thank you!

Highlighted
Atom

Hi Andrew,

 

I have a similar query to this. Just that in my case i need a specific value to repeat itself multiple times, till a change of condition in the underlying column. For e.g.see below:

 

For every change in Level to equal 2 (i.e Level =2) I need the corresponding "DESC" of that Level 2 occurrence to repeat for all subsequent records in a separate column, till the next available instance of Level 2 with a different DESC. The occurrence of "Level =2" will be dynamic, i.e. can occur after any n number of records.

 

UNITLEVELDESCRequired Mapping
A_XYZ2XYZXYZ
A_33aaaaXYZ
A_44bbbbXYZ
A_55ccccXYZ
A_66ddddXYZ
A_77eeeeeXYZ
A_88fffffXYZ
A_ABC2ABCABC
A_93gggggABC
A_104hhhhABC
A_115iiiiiiABC
A_126jjjjjABC
A_137kkkkkABC
A_148llllllABC
Labels