Hi all, hope you’re doing great!
I have a data table as below:
What I want is to append a new column, for which each row’s cell value will be a combination of the column names that have values. To illustrate, it’d look like something below:
Now, there are a few additional challenges:
- I need to add a separator to the column names when combined, so that the output is “readable”. In the example, I used " + ";
- I must avoid for instance simply adding a space in the combination for columns that have no data (so that in the case of Row3 I don’t end up with a double space at the beginning such as " NAME SURNAME C");
- Finally, I have many columns (and their names/amount might change depending on my input file), so I’m thinking something using FlowVariables & loops so I have a scalable solution
Any helpful thoughts?
Thanks a mill,
Thanks for your response, I was able to use your example + some creativity to get what I wanted.
This seemed like an interesting task so I played around a bit with it and here is my solution.
Go column by column and with Column Expressions node replace values with header names or empty string. After that combine columns and a bit of string manipulation functions does the job. Did you do something similar?
Workflow is attached if you are interested.
2019_03_07_Header_Names_Manipulation.knwf (27.8 KB)
Also if no secret what is the use case behind it? Already been similar requests (although not including Header names!) to loop over multiple columns and I got a feeling a smarter approach should be available…
Hi @ipazin ,
Yes, I did something very similar, it just had a few extra steps due to the nature of my data.
Indeed I can’t get into too much detail, but essentially the case was that I had a list of stores, products and the products sales in those stores, and what I wanted to do was to segment those stores according to the portfolio that was sold.
So naturally I could have I very high number of potential portfolio combinations, depending of the total number of products and the maximum amount of products a store could handle. Even if we weren’t talking about the possible ones but the actual combinations seen, this number would be pretty high to try and do it by hand through some crazy =IF() rule in excel.
I can see this being used in similar such cases of wanting to ‘tag’ or cluster a set of observations according to a combination of factors.
I see. A bit clearer now what were you doing
Tnx for a explanation and good luck,
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.