Start Free Trial

Alteryx Designer Desktop Discussions

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

Assign a value for a range of rows based on the value of a single row.

hellyars
13 - Pulsar

I have been playing with the Python tool (with help). 


The following function works.

Basically, if the 9th row has a value of 'Recommended' in the field RAW then assign the value 'HEADER' in LOD for rows 1-10.

Otherwise  if the 7th row has a value of 'Recommended' in the field RAW then assign the value 'HEADER' in LOD for rows 1-8.

 

It does work, but the Python Tool can slow things down so I am trying to off-load some of the basic functions to other Alteryx tools.

 

My question:  How do you do this with an Alteryx function or some combination of tools other than the Python Tool.

 

Something along the lines of if [ROW]=9 and [RAW]='Recommended' then [assign 'HEADER' as the value for LOD in rows 1-10]

 

 

 

def assign_header_values(df):
    # Check the 9th row in RAW for "Recommended"
    if df.loc[8, 'RAW'] == 'Recommended':
        df.loc[0:9, 'LOD'] = 'HEADER'  # If true, assign 'HEADER' to rows 1-10 in LOD
    # Check the 7th row in RAW for "Recommended"
    elif df.loc[6, 'RAW'] == 'Recommended':
        df.loc[0:7, 'LOD'] = 'HEADER'  # If true, assign 'HEADER' to rows 1-8 in LOD
    return df

 

 

 

Sample Data.

 

3 REPLIES 3
danilang
19 - Altair
19 - Altair

Hi @hellyars 

 

It should be easy in the workflow itself.  Can you provide some sample data?

 

Dan

 

hellyars
13 - Pulsar

@danilang 

 

Scenario 1.  Scenario 2 below

 

ROWRAWLODDESIRED OUTCOME
1

Yada

 HEADER
2Yada HEADER
3Yada HEADER
4Yada HEADER
5Yada HEADER
6Yada HEADER
7Yada HEADER
8Yada HEADER
9RecommendedHEADERHEADER
10Yada HEADER
11Yada  

 

Scenario 2

 

ROWRAWLODDESIRED OUTCOME
1

Yada

 HEADER
2Yada HEADER
3Yada HEADER
4Yada HEADER
5Yada HEADER
6Yada HEADER
7RecommendedHEADERHEADER
8Yada HEADER
9Yada  
10Yada  
11Yada l

 

danilang
19 - Altair
19 - Altair

Hi @hellyars 

 

This will work for both of your scenarios

 

danilang_0-1687371461952.png

Basically just find the header row and use it's row number to populate the correct rows

 

Dan 

Labels
Top Solution Authors