I have a situation where I need to dynamically rename some columns that but not others. The challenge arises because the columns I want to change are month/year that change month to month. I need to dynamically the first image of columns to look like the second image. Any logic I try to use in the expressions field does nothing. In all cases the tool accepts the expression, but the expression is ignored. In all cases, the
Here are a few I have tried to no avail.
a. IIF([_CurrentField_] IN ("sort_order","mtd_reporting","branch","state"),[_CurrentField_],Replace(Right([_CurrentField_],Length([_CurrentField_])-4),"_"," "))
b. IF [_CurrentField_] IN ("sort_order","mtd_reporting","branch","state") THEN [_CurrentField_]
ELSE Replace(Right([_CurrentField_],Length([_CurrentField_])-4),"_"," ")
ENDIF
c. IF ToNumber(Left([_CurrentField_],1)) >= 0
THEN Replace(Right([_CurrentField_],Length([_CurrentField_])-4),"_"," ")
ELSE [_CurrentField_]
ENDIF
If I manually check all the dated columns and none of the others, it works fine. But that's not "dynamic" in the way I need it.
What am I doing wrong?
From this...
To this...
Configuration:
@MeanLeanDean
Based on my test, you are on the right track.
I only added a RegMatch function to judge if the Filed Name is in the patter of "3digit_3 Letters_4 digits", then the rest is just same as your formula.
@MeanLeanDean Another way of doing this with the string functions
IIF(EndsWith([_CurrentField_],'_'+toSTring(DateTimeYear(DateTimeNow()))),
Replace(SubString([_CurrentField_],FindString([_CurrentField_],'_')+1,Length([_CurrentField_])),'_',' '),[_CurrentField_])
Thanks, @Qiu and @binuacs , for your responses. Like my attempts, your recommendations on work for fields that are checked in the field selection window. They don't work if all that is checked is "Dynamic or Unknown Fields", which I need it to do because the field names change dynamically from month to month and I'm trying to avoid having to manually check the box for each new month every month.
@MeanLeanDean Both the solutions are dynamic, first it checks for the field names ends with current year then applying the logic only for those field names. If you are getting different output can share some more sample data end expected result
@binuacs
Thank you for the comments.
I also believe they are all dynamic. 😀
The first image in the original post is the source and the result when the tool is configured as in the image above, hence the need for the conditional logic to ensure that only the date fields are modified. It's as if the tool is no working as advertised.