We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Add +1 to a year or digit in a string

tcrawf
5 - Atom

I'm currently building a workflow that needs to roll forward the year in a string. It's all in the same column and would need to just increase by one year. See some examples below:

 

Original: Contract calculation for FY24-25

Need to update to: Contract calculation for FY25-26

 

Original: FY23-24 Employment Agreements

Need to update to: FY24-25 Employment Agreements

 

Original: TB detail as of 6/30/2024 in excel

Need to update to: TB detail as of 6/30/2025 in excel

 

Original: GL detail 7/1/2023 - 6/30/2024

Need to update to: GL detail from 7/1/2024 - 6/30/2025

 

I've tried Replace and REGEX_Replace functions but still running into issues. Any help is appreciated!

4 REPLIES 4
Yoshiro_Fujimori
15 - Aurora
15 - Aurora

Hi @tcrawf 

As each date / year represents different meaning, you should create a separate column for each date / year.

That would make your analysis much easier going forward.

Yoshiro_Fujimori
15 - Aurora
15 - Aurora

I tried to solve this as a challenge.

Please note that the workflow depends on the input data pattern, and you may need to modify it as you find issues.

 

Input Data

Field1
Contract calculation for FY24-25
FY23-24 Employment Agreements
TB detail as of 6/30/2024 in excel
GL detail 7/1/2023 - 6/30/2024

 

Workflow

AddOneYear_workflow.png

 

Output Data

Field1
Contract calculation for FY25-26
FY24-25 Employment Agreements
TB detail as of 6/30/2025 in excel
GL detail 7/1/2024 - 6/30/2025
flying008
15 - Aurora

Hi, @tcrawf 

 

FYI.

 

(\d{2}-\d{2})|(\d+/\d+/\d{4}\s?-?\s?(\d+/\d+/\d{4})?)
IIF(Length([Get]) =2, ToString(ToNumber([Get]) + 1), Left([Get], Length([Get]) -4) + ToString(ToNumber(Right([Get], 4)) + 1))
Trim(IIF(Contains([Txt], 'FY'), REGEX_Replace([Txt], 'FY\d{2}-\d{2}', 'FY' + Replace([Get], ' ','')), REGEX_Replace([Txt], '\d+/\d+/\d{4}\s?-?\s?(\d+/\d+/\d{4})?', [Get] + ' ')))

 

录制_2024_10_11_11_21_38_450.gif

 

录制_2024_10_11_11_23_03_400.gif

PangHC
13 - Pulsar

I more preferred to use the text input method (in app/ .yxwz) to help here. which need not to take the timestamp but straightforward to build the title instead.

Screenshot 2024-10-11 144922.png

Labels
Top Solution Authors