How To Gather Items Based on Starting String?

Dears,

How To Gather Items Based on Starting String ?
Let me explain: I want to search for item in Column B , if it starts with any item from Column A than I will put it in the same Row as this Latter as show in below example :

image

Thanks in Advance

There are several ways on how to do this:

  1. Read the data from excel with the read range activity

  2. Initialize a new empty dictionary. We’ll save everything here

image

  1. Go through your datatable and put the data where it belongs
For each currentRow in datatable
    if currentRow not empty
        dictionary(colA) = get all colBs where colB starts with currentRow.colA
        

Now we have a dictionary with our results, we only need to put this back in our desired format.
TBH I think your format is a bit weird but you can do it however you’d like.

Either use another for loop to work through the dictionary or don’t even use the dictionary in the first place and format everything like you want directly in step 3.

I’ll attach an example .xaml

getitems.xaml (6.9 KB)

If this has helped you, please mark this answer as the solution.

1 Like

Thanks @T0Bi , Which Activities you’ve used ?

image

Those are basic Core Activities. This is a for each row activity

image

Which version are you on?

1 Like

I’m using : Studio 2020.10.7

image

Not possible to install those packages in my Studio? If this is the case, Could you please share print screen of those "For Each " Activities I will implement them from my Side.Thanks

Mate you really should upgrade to 21.4
You’re missing out on lots of new features.
image

NOT String.IsNullOrEmpty(CurrentRow("Column A").ToString)

Assign:

tmpDictionary(CurrentRow("Column A").ToString) = dtInput.Select("Convert([Column B],System.String) LIKE '" + CurrentRow("Column A").ToString + "*'").Select((Function (x) x.Item("Column B").ToString)).toList

If this has helped you, please mark this answer as the solution.

1 Like

Thanks @T0Bi , ForEach Activity Issue Is Fixed, but How to Write Data as per the below and where is Column C and Column D in the Formula ?

image

I’m not going to build your whole process. You should be able to use a for each loop and go through the dictionary.

I don’t need column C or D in the formula.
The formula simply combines everything from the input datatable so you can use it for whatever you want.

The result is a dictionary which is build like this:

12: {129945, 124432}
34: {342377, 349999, 341111},

As you have a variable and no predefined number of columns, I didn’t use a datatable for the result.

Edit: After checking your profile I saw that you’re basically letting other people build processes for you all the time, how about doing something yourself for a change…

Thanks @T0Bi for your explanation and advice, in fact I’m learning a lot from people who push me to create workflows rather than sharing the same, and this is what I’m doing all the time. Except sometimes when I’m limited by time i ask for building workflows…because RPA is not my only Job, I’m doing it for pleasure and to help me in my daily JOB and I don’t want it to Impact my main JOB. Thanks again for Your Solution :+1:

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