Alteryx Designer Desktop Discussions

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

Dynamic rename a field conditional on today's date

Anna92
6 - Meteoroid

Hi Alteryx community,

 

I've been wrestling with this one, but I have a workflow I'm putting together where a field name changes every month based on the following parameters:

 

I am using 2024 as the current year and 2023 as the prior year in this example, but this attribute is dynamic as well. 

 

If today's month is...Then the field name should be...
January of the current yearSum of Jan - Dec 2023 [prior year] Flows
February of the current yearSum of Jan 2024 [current year] Flows
March of the current yearSum of Jan - Feb 2024 Flows
April of the current yearSum of Jan - Mar 2024 Flows
May of the current yearSum of Jan - Apr 2024 Flows
June of the current yearSum of Jan - May 2024 Flows
July of the current yearSum of Jan - Jun 2024 Flows
August of the current yearSum of Jan - Jul 2024 Flows
September of the current yearSum of Jan - Aug 2024 Flows
October of the current yearSum of Jan - Sep 2024 Flows
November of the current yearSum of Jan - Oct 2024 Flows
December of the current yearSum of Jan - Nov 2024 Flows

 

I tend to wrestle with datetime conditional formulas and I've attempted many variations but they either return a malformed if statement or error that the formula can't convert the date. Any ideas you guys have would be so appreciated. Thank you! 

1 REPLY 1
Anna92
6 - Meteoroid

Praise the freaking Lord, I figured it out. Gonna post solution in case anyone else runs into this issue.

 

I don't know why this works, but it works so if someone wants to comment about the data types that impacts this conditional formula, please let me know. Thank you! 

 

If DateTimeFormat(DateTimeToday(),"%b") = "Jan" then

"Sum of Jan - Dec " + DateTimeFormat(DateTimeAdd(DateTimeToday(),-1,"year"),"%Y") + " Flows"

 

elseif DateTimeFormat(DateTimeToday(),"%b") = "Feb" then

"Sum of Jan " + DateTimeFormat(DateTimeToday(),"%Y") + " Flows"

 

elseif DateTimeFormat(DateTimeToday(),"%b") = "Mar" then

"Sum of Jan - Feb " + DateTimeFormat(DateTimeToday(),"%Y") + " Flows"

 

elseif DateTimeFormat(DateTimeToday(),"%b") = "Apr" then

"Sum of Jan - Mar " + DateTimeFormat(DateTimeToday(),"%Y") + " Flows"

 

else [_CurrentField_] endif

Labels