dynamic Column header

Hello knimers,
I m working on a report in which i have to compare 2 periods against each other, and the name of these periods changes (at a time it can be month 5 and 4 and at a different time it can be month 5 and 6) which is why i renamed to p2 and to p1 to avoid keep writing and changing math formulas and rule engine every time. However, how can i revert to the old names.

I though of unpivoting then using string manipulation, but is there a better way?

Hello @mh_elhassan
You need to store original names somewhere. What about createing variables keeping those names?
Just an idea…
Happy KNIMEing

@Kazimierz thanks. the names are still available in previous nodes. I am not sure i got how we can achieve it

@mh_elhassan I’m not sure how your workflow looks like, but my idea was to:

  1. Extract and store original names somewhere. I would use two variables here, one variable for each name.
  2. Refer to variables where you rename back to original names.
    Could you please show/share your workflow?

Hello @mh_elhassan,

there are multiple ways to deal with this. Here is one:

Trick is to use Extract Column Header to get “standard” column names. Then you can apply your logic and bring back original column names with Insert Column Header node.

Workflow example attached.
dynamic_column_ipazin.knwf (12.4 KB)

You have to be careful to always have same table structure but again there are nodes that can help you with it like Table Validator or Table Validator (Reference).

Additionally Column Expressions node can access column values based on it’s index so you could build and apply your logic in it without changing column names.

Br,
Ivan

4 Likes