Identify Latest Version of Column

Hi Guys,

I’m curious with my case if it’s possible in knime platform. Here’s my sample data.

Please note the following:
1/Higher Number Version means Latest Version
2/If the latest version of ID Column is TRUE set the Older version as TRUE else FALSE for both
Version.
3.My ID Column is my identifier.

ID Version For Monitoring Revised For Monitoring Remarks
123 5 TRUE TRUE Latest Version is TRUE
456 5 FALSE FALSE Latest Version is FALSE
789 5 TRUE TRUE Latest Version is TRUE
123 4 FALSE TRUE Latest Version is TRUE
456 4 TRUE FALSE Latest Version is FALSE
789 4 FALSE TRUE Latest Version is TRUE

Thank you!
Sample Data.xlsx (12.2 KB)

Hello @seanmanzanilla … if I understand you correctly, you want the Latest Version to follow the value assigned to the “Revised For Monitoring” column regardless of any value assigned to the “For Monitoring”?

Consider this:

1 Like

Hi @seanmanzanilla , I’m not sure I understand the data, more precisely in relation to your point #2 .
“…Column is TRUE set the Older version as TRUE…”. Which column is that? There are 3 columns that have “TRUE” and “FALSE”. Unless the “Revised Monitoring” is not part of the input, and it’s the “For Monitoring” column that has to be modified, and the “Revised Monitoring” is showing what is expected?

It’s always better to show the input data separately and then show what the expected output is.

For the solution, the high level approach would be to get the latest version of each ID, and this can be done by a GroupBy. You then join this results with your data by joining on ID. You can now do your comparison as you pleased based on the rule you mentioned.

For the sake of the demo, I will assume that the “For Monitoring” is part of the input, and the “Revised Monitoring” is what needs to be generated. I have no idea what the Remarks means, if not just kind of duplicating the results? Anyways, here’s the input I’m using:
image

Something like this would do:
image

Result:
image

Here’s the workflow: Identify latest version of column.knwf (22.4 KB)

Not sure if the Remarks column is needed, but if you need it, you can just create it via String Manipulation like this:
image
with this Expression:
join("Latest Version is ", $Revised Monitoring$)
Like this:

This will add the Remarks column:
image

1 Like

Hi @seanmanzanilla , I had not noticed @badger101 had written something while I was writing my answer. But you can see based on @badger101 's comment that it confirms the confusion around your data.

Just repeating what I said, it’s better to clearly show what the input data we have to work with, and what the expected output should be, both shown clearly and separately.

And as my motto goes: “Help us help you. The more accurate you are in your information, the more accurate the solution will be”.

2 Likes

Hi @badger101 @bruno29a,

Sorry for the confusion about the output data.

Here’s my sample and more detail output.

As you can see I will only depend on latest version means (Higher Value) if the for monitoring true/false of ID Column.Will overwrite the older version and depend on the latest version.

Let’s Assume Today to Process Sample Data Day 1
Sample Data Day 1
Input Data
ID Version For Monitoring
123ABC 5 TRUE
456DEF 5 FALSE
789GHI 5 TRUE
123ABC 4 FALSE
456DEF 4 TRUE
789GHI 4 FALSE
Output Data
ID Version For Monitoring Revised For Monitoring
123ABC 5 TRUE TRUE
456DEF 5 FALSE FALSE
789GHI 5 TRUE TRUE
123ABC 4 FALSE TRUE
456DEF 4 TRUE FALSE
789GHI 4 FALSE TRUE
Let’s Assume the expected data to process for the next day or day 2 is like this sample
Sample Data Day 2
Input Data
ID Version For Monitoring
123ABC 5 TRUE
456DEF 5 FALSE
789GHI 5 TRUE
123ABC 4 FALSE
456DEF 4 TRUE
789GHI 4 FALSE
123ABC 6 FALSE
456DEF 6 TRUE
789GHI 6 FALSE
Output Data
ID Version For Monitoring Revised For Monitoring
123ABC 5 TRUE FALSE
456DEF 5 FALSE TRUE
789GHI 5 TRUE FALSE
123ABC 6 FALSE FALSE
456DEF 6 TRUE TRUE
789GHI 6 FALSE FALSE
123ABC 4 FALSE FALSE
456DEF 4 TRUE TRUE
789GHI 4 FALSE FALSE

Thank you for helping people like me.

Thanks for the additional information @seanmanzanilla .

So, does it mean that my workflow works for what you need? What you explained is what the assumption I made when I built the workflow as I explained in the post.

1 Like

Hi @bruno29a ,

Yes it works, thanks a lot!

1 Like

Are there always 2 versions in the dataset or could be more then in the example?

1 Like

Hi @Daniel_Weikert it could be more than.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.