Alteryx Designer Desktop Discussions

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

How to rename a column based on it's column position... e.g, F21 of F24?

SDJ57
8 - Asteroid

I have a dataset where I need to dynamically rename two columns based on their column position for changes made to reflect a new year. I am able to pull the field information and date into a stream where I use the Dynamic rename tool, but this isn't connected to the full dataset.

 

Thinking there should be an easier way to do this. Right now I am trying to transpose the columns to rows and then figure out a way to rename based on position this way. Below is a very simple visual of what I am needing to accomplish. Rename the name of the 4th column to a NewName.

 

SDJ57_0-1675452379062.png

 

17 REPLIES 17
SDJ57
8 - Asteroid

Hi @binuacs, I think that would get it, but I'm really not REGEX literate lol. There are 4 years with the same name structure but different years. So the exact format is "FY YYYY" descending down by year. So, the first one is in column 21 and the 2nd that I need is in column 24 the other 2 are in position 27 and 30.

 

Column #21 needs to be FY "Next Year" and Column #24 needs to be FY "Current Year"

 

SDJ57_0-1675454784558.png

 

ShankerV
17 - Castor

Hi @SDJ57 

 

Please find the tweaked formula for Year 2022.

 

IF contains([_CurrentField_],("Year "+left(datetimeadd(DateTimeNow(),-1,"year"),4)))
THEN "NewName"
ELSE [_CurrentField_]
ENDIF

 

 

ShankerV_0-1675455100395.png

 

 

Many thanks

Shanker V

ShankerV
17 - Castor

Hi @SDJ57 

 

Please find the output for FY 2022 and FY 2021.

 

IF contains([_CurrentField_],("FY "+left(datetimeadd(DateTimeNow(),-1,"year"),4)))
THEN "Next Year"
ELSEIF contains([_CurrentField_],("FY "+left(datetimeadd(DateTimeNow(),-2,"year"),4)))
THEN "Current Year"
ELSE [_CurrentField_]
ENDIF

 

ShankerV_0-1675455402993.png

 

 

Input was:

ShankerV_1-1675455426831.png

 

Many thanks

Shanker V

SDJ57
8 - Asteroid

Thank you @ShankerV! This will work! =)

binuacs
20 - Arcturus

@SDJ57 Updated the workflow

 

binuacs_0-1675457109815.png

 

SDJ57
8 - Asteroid

Thank you @binuacs! That is slick, I haven't used the tile before!

binuacs
20 - Arcturus

@SDJ57 sorry I misunderstood your requirement, Do you mean to add the text "Next Year" instead of adding the given year + 2? 

SDJ57
8 - Asteroid

@binuacs no, you got it correct. I shouldn't have had a quote around that text as I was referring to the literal number of the next year. Thank you!

Labels