Defining Parameters on Closest Value

Hello,

I’m working with a dataset (attached below) where there are multiple sizes for a single “Item”. The goal is to have only 5 sizes per “item”, where each size is specifically 1, 5, 25, 100, or 500. However, if any of those specific sizes are not available, then choose the item with the closest next value.

Some items may not have a total of 5 sizes (i.e. an “item” could only have 1-4 sizes), then that’s okay, still would like to retain the same logic above (i.e. choose the closest value to 1, 5, 25, 100, or 500) for all available sizes.

Really appreciate the community’s support!!

Thanks,

knime_ex.xlsx (250.2 KB)

without looking at the data:

just run 5 loops (or vectorize everything in one go) subtracting your values and then picking the smallest, absolute record for each item.

if closest “next” means only going into larger sizes, then just discard all negative values after subtraction

Hi,

Thanks for your response! I understand what you’re getting at, but am unfamiliar with looping. When it comes to generating the workflow, can you share some advice on successfully creating the loop for this? Meaning, which loop node would you suggest I use to perform the subtraction against my values?

Appreciate your time.

based on ur specific needs … understand this might not be exactly what you need. if it’s not the right fit, let’s keep brainstorming."

rgds

@marzukim , thank for your reply! I tried doing a rule-based row filter, but it gets tricky because say the size 1 isn’t available, but 0.5 is, then that would be an okay substitute on behalf of the 1. So then the acceptable size options for that item would then 0.5, 5, 25, 100, and 500. @fe145f9fb2a1f6b was on the right track for me I think, I’m just not too familiar with looping. Unless there’s another way to integrate a rule that depicts the next highest/lowest value

Try this. Simple, no loops.


4 Likes

similarity search can work but you need to add a duplicate row filter grouped on the items and the 5 sizes taking the minimum of the distance only.
and you need to add another rule-based row filter if you want to consider only item-sizes that are larger or smaller of your reference values.

my approach would look similar with the reference table being the loop starter.
you could pipe everything in if you wont mind double selections. but if you dont want to pick something twice, an iterative loop, or a duplicate row filter at the end, would be required.

2 Likes

Thanks everyone! @rfeigel this got me where I needed to go, and @fe145f9fb2a1f6b your suggestions helped define my specific use case.

Appreciate all the help!!

Regards,

2 Likes