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.
Solved! Go to Solution.
Scenario 1. Scenario 2 below
| ROW | RAW | LOD | DESIRED OUTCOME |
| 1 | Yada | HEADER | |
| 2 | Yada | HEADER | |
| 3 | Yada | HEADER | |
| 4 | Yada | HEADER | |
| 5 | Yada | HEADER | |
| 6 | Yada | HEADER | |
| 7 | Yada | HEADER | |
| 8 | Yada | HEADER | |
| 9 | Recommended | HEADER | HEADER |
| 10 | Yada | HEADER | |
| 11 | Yada |
Scenario 2
| ROW | RAW | LOD | DESIRED OUTCOME |
| 1 | Yada | HEADER | |
| 2 | Yada | HEADER | |
| 3 | Yada | HEADER | |
| 4 | Yada | HEADER | |
| 5 | Yada | HEADER | |
| 6 | Yada | HEADER | |
| 7 | Recommended | HEADER | HEADER |
| 8 | Yada | HEADER | |
| 9 | Yada | ||
| 10 | Yada | ||
| 11 | Yada | l |
Hi @hellyars
This will work for both of your scenarios
Basically just find the header row and use it's row number to populate the correct rows
Dan
