Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Producing additional rows and creating a record id

Sammy22
8 - Asteroid

I have a table with sales information for quotes and can contain more than one row with varying quantities of the product. I first need to make the quote table to have one row for each product (so 4 rows for beans and 4 for bread) and then add a record id like thing for each record in a QID. 

current

Q IDProductQuantity
PB123Beans2
PB123Beans2
PB123Bread4

needed

Q IDProductQ Product LevelQuantity
PB123BeansPB123-11
PB123BeansPB123-21
PB123BeansPB123-31
PB123BeansPB123-41
PB123BreadPB123-51
PB123BreadPB123-61
PB123BreadPB123-71
PB123BreadPB123-81
9 REPLIES 9
atcodedog05
22 - Nova
22 - Nova

Hi @Sammy22 

 

Here is how you can do it.

 

Workflow:

atcodedog05_0-1627464718627.png

 

1. Using gen rows to generate rows equal to quantity.

2. Using record id tool to set row id.

3. Using formula creating Q Product Level by concating Q ID and row ID.

4. Using select tool to keep only required columns.

 

Hope this helps : )

Ladarthure
14 - Magnetar
14 - Magnetar

Hi @Sammy22,

 

basicaly to do so you can use the generate rows which nallows to have more rows from 1 item as a quantity and then generate the ID needed. Find attached an example around this

Emil_Kos
17 - Castor
17 - Castor

Hi @Sammy22,

 

I was a little bit slow this time 😀

 

Emil_Kos_0-1627465121977.png

 

Output:

 

Emil_Kos_1-1627465134070.png

 

 

Sammy22
8 - Asteroid

The problem here is there are duplicate ID eg. PB123-1. For one QID there should be unique IDs (from PB123-1 to PB123-8 in this example). I have tried to remove product from the summarize and the QID works correctly but then i will lose that product field which i need. I somehow need the original QID, product columns alongside the ID.

atcodedog05
22 - Nova
22 - Nova

Hi @Sammy22 

 

You can provide us a sample data, sample output and the logic. We might be able to help you out.

Emil_Kos
17 - Castor
17 - Castor

Hi @Sammy22,

 

I updated my workflow and you will have the old ID alongside the new one:

Emil_Kos_0-1627467322582.png

 

Sammy22
8 - Asteroid

Still not quite there. I have added additional QID as that is how the data is. You can see in the outcome PB123 will have 8 unique IDs and PB345 will have 3.

 

Q IDProductQuantity
PB123Beans2
PB123Beans2
PB123Bread4
PB345Milk1
PB345Eggs2

 

outcome needed

Q IDProductQ Product LevelQuantity
PB123BeansPB123-11
PB123BeansPB123-21
PB123BeansPB123-31
PB123BeansPB123-41
PB123White BreadPB123-51
PB123White BreadPB123-61
PB123White BreadPB123-71
PB123White BreadPB123-81
PB345MilkPB345-11
PB345EggsPB345-21
PB345EggsPB345-31
atcodedog05
22 - Nova
22 - Nova

Hi @Sammy22 

 

Here is how you can do it. I am using multi-row formula tool groupby QID to create group record id.

 

Workflow:

atcodedog05_0-1627469245658.png

 

Assuming Bread and White Bread are the same.

 

Hope this helps : )

Emil_Kos
17 - Castor
17 - Castor

Hi @Sammy22,

 

I have created an alternative solution to @atcodedog05. I used the running total instead of the multi-row formula. 

 

Emil_Kos_0-1627469935958.png

The output:

 

Emil_Kos_1-1627469948973.png

 

Labels
Top Solution Authors