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

Alteryx Designer Desktop Discussions

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

Generate new row and copy data from specified row above based on condition

snwk
5 - Atom

Hi guys, I'm new to Alteryx and couldn't figure out a way how to do this, maybe someone can help.

I have an input table that looks like the following:

Location (header)
Berlin
Berlin
Munich
Munich
London
London

I'd like to generate a new row whenever there's a new location (active row does not equal row -1) and copy the data from the first row (header). The Output should look like this:

Location
Berlin
Berlin
Location
Munich
Munich
Location
London
London

 

It would also be necessary to save every location in a new excel sheet (within the same workbook). 

 

Thanks and kind regards!

14 REPLIES 14
ShankerV
17 - Castor

Hi @snwk 

 

If your end goal is to save the city names in different files, there is no need to populate the Location eachtime.

 

The header will be populated in the excel output.

 

 

ShankerV
17 - Castor

Hi @snwk 

 

Please find the expected output.

 

ShankerV_0-1674121724570.png

 

 

ShankerV_1-1674121735102.png

 

ShankerV_2-1674121746821.png

 

Input was:

 

ShankerV_3-1674121765958.png

 

ShankerV_4-1674121777593.png

 

 

 

 

ShankerV
17 - Castor

@snwk 

 

Output tool settings:

 

ShankerV_0-1674121893218.png

 

Many thanks

Shanker V

 

snwk
5 - Atom

Sorry, I forgot to specify this: There are basically 2 header rows, not 1. I managed to save it in different sheets, but of course the "second" header row is missing.

Location (header)
2nd header
Berlin
Berlin
Munich
Munich
London
London
ShankerV
17 - Castor

Hi @snwk 

 

So you need both header in your output sheet?

 

Or only the 2nd header is enough in the output sheet.

 

snwk
5 - Atom

Yes, exactly

ShankerV
17 - Castor

Hi @snwk 

 

One way of doing this.

 

ShankerV_0-1674122853527.png

 

Many thanks

Shanker V

ShankerV
17 - Castor

Hi @snwk 

 

Step 1: Input

ShankerV_0-1674122889373.png

Step 2:

ShankerV_1-1674122948522.png

 

 

Step 3: 

 

ShankerV_2-1674122964665.png

 

 

 

IF [RecordID]<=2
THEN 0
ELSEIF [Location]=[Row-1:Location]
THEN 0
ELSE 1
ENDIF

 

ShankerV_3-1674122995451.png

 

Many thanks

Shanker V

 

 

ShankerV
17 - Castor

Hi @snwk 

 

Step 4: Formula tool

ShankerV_0-1674123049187.png

 


IF [Temp]="1"
THEN "2nd header"
ELSE [Temp]
ENDIF

 

ShankerV_1-1674123059506.png

 

Step 5:

ShankerV_2-1674123108496.png

ShankerV_3-1674123119341.png

 

Step 6: 

 

ShankerV_4-1674123138294.png

ShankerV_5-1674123146693.png

 

Many thanks

Shanker V

 

 

 

Labels