Compare row values to find closes match and return column name

Long time reader, first time posting.
I’m beginner with UiPath (and programming overall) but I’ve managed to utilize the community so far to get my way.

Now I’m at point where I would need some guidance and help.

I have two different data tables, from where I would need to find the closes match and return the column name from dt1 (eg. S). Data tables share the row ID which I can use to find the correct row index.

I have “for each row in dt1” - to collect all rows.
Then I find the “row items” so that I can use "if the rowID=“row name” to find the correct row.

  • How do I loop through the dt1 row values to find the closest match to dt2 value?
  • When I find the match, my idea was to use the dt1 match index to check the column name on the same index, but again I would need some advice how to achieve this?

Conditions for the value match could be something like:
length +/- 5
width +/- 5
depth +/- 1

dt1.xlsx (8.7 KB) dt2.xlsx (8.6 KB) help DT match.xaml (10.9 KB)

Hope someone can direct me forwar.

with the row transponation from dt1 the job can be done more easy. About the expected output it was unclear from the description and it is prototyped to following:


find starter help here:
ClosestMatch2.xaml (25.1 KB)

As you mentioned that you are UiPath Beginner I balanced Linq vs. essential activities just to give you a more easy start. For datatable row transponation also have a look here:

Let us know yout open Questions

Thanks for the starter!
Just for understanding you transposed the dt1?

Scenario that I have is something like this, not sure if this makes it any more clearer:
I would have customer provided measurements (dt2) and I would need to find out which size (from dt1 column names) would be the best match in our default sizes.

@Mkk0 So for the Input files that you have provided, Would the Column Name, that you would want as the Output would be Column Name “M” ?

Also Is that the alone output that you need? Or do you have another representation of output in mind? If you have please Provide the Expected one.

the request is providing custom sizes and return the corresponding the Class (S,M…) is possible and also implemented in the starter help. What you can do is to adopt result report / matching info retrieval to only catching the matching class.

As you can see in the demo result the class M is reported as matching class for the given custom sizes

Let us know your open question

1 Like

If there is match between dt1 and dt2 then only the column name is required.

find updated xaml here:
ClosestMatch2_V2.xaml (24.7 KB)



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