0

I'm looking for a way to use Alteryx for the following data wrangling task.

I have a table like this:

Var1 Var2
A 1-3
B 0-2

and I would like that to result in this:

I have a table like this:

Var1 Var2
A 1
A 2
A 3
B 0
B 1
B 2

So I'm trying to "break open" the list of numbers in Var2 and create a row for every possible number in the range.

ulima2_
  • 1,276
  • 1
  • 13
  • 23
  • 1
    Could you do a GenerateRows tool to generate integers from 0 to some number larger than your max(Var2)... then join that to your table (cartesian product), then filter on GeneratedRow >= Var1 and <= Var2? – johnjps111 Sep 13 '21 at 19:50

2 Answers2

0

I extended on the answer of @johnjps111: Use a GenerateRows tool, but for Initialization Expression use the start value. and for Condition Expression force the new column (e.g. "RowCount") to be RowCount <= EndValue.

No join necessary in this way!

ulima2_
  • 1,276
  • 1
  • 13
  • 23
0

And to make it more clear, the initialization expression would be something like:

(regex_replace([var2],"(\d+).*","$1"))

and the condition expression would be something like:

RowCount <=  tonumber(regex_replace([var2],".*(\d+)$","$1")) 
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
WDGITH
  • 26
  • 1