Result Flagged Columns

Hello everyone, I would like to use KNIME to create a new column for each row that contains the names of the columns in which an exclamation mark (“!”) appears.

Example:
Column A = !; B = 5; C = !
Output: Flagged Columns → A, C

Thanks in advance for your help.

@Paintman13 welcome to the KNIME forum. Maybe you can provide an example and read your description again because I do not fully understand what your task is. Is it the column names that contain ! or is it rows?

2 Likes

Is your input all in one cell as shown below? That’s what your post implies. Also do you want the output in one cell separated by commas? Can there be an arbitrary number of columns? Finally, can there be more than one row? If you could upload a complete sample input and output (not a truncated example) it would be helpful.

1 Like

Hello, and thank you for your reply. Here is an example:

@Paintman13 here is one way to do this

3 Likes

I’ve taken the opportunity to attempt this using my “Rule Engine (Multi-Column)” component along with a Column Aggregator. The component provides similar functionality to the standard Rule Engine Node, but with extensions to the rules to allow for multi-column working.

This allows it to create a series of columns containing the column name of any column containing “!” on each row, using the following rule:

$CURRENTCOLUMN$ = "!" => "<CURRENTCOLUMNNAME>"

This set of appended columns are then concatenated using Column Aggregator

The component is available here and works with KNIME 4.7.8 onwards

Behind the scenes it is doing quite a lot of operations to convert the additional rules to work with the standard Rule Engine iterating over columns, so it’s not necessarily quick to perform on large datasets but is a trade off against simplicity of configuration.

2 Likes

Here’s an alternative approach using Unpivot, Rule Engine and Group By with the results then joined back to the original

2 Likes

Hello, and thank you for your reply. Here is an example:

image

image541×299 5.65 KB

Thank you very much. That was really helpful. Could you also tell me how to configure the Joiner node so that I can append the result column to the original table?

@Paintman13 not really sure what you mean by joining the results. Maybe you start using sample data instead of screenshots which makes it easier to understand what it is you are trying to do. Also what is helpful is a complete description of the task instead of amending it on the go :slight_smile:

1 Like