Update MainDT using filtered rows

Team,

Can someone provide input on below logic

  1. Read sheet data as MainDT
  2. Apply filter on MainDT and stored in FilterDT
  3. Iterate loop on FilterDT and perform the actions
  4. Update the those row from MainDT where action performed on filterDT rows

Hi @Omkar_Deshmukh
Can u explain your process a little bit , like what actions u had to perform on the FilteredDt and all?

Hi, screenshot of input file data and expected output.along with filter details

Hi @Omkar_Deshmukh,

The important thing when you want to update an original DT (MainDT) is to have column values which will not change in both MainDT and FilterDT.

Think of it as a Foreign key. No matter how many rows the FilterDT has it always will have a corresponding Foreign key which is found in MainDT.

There are many ways to achieve this. Here is one Example:
Below I treat Header1 as the Foreign key

MainDT

Header1 (int) Header2 (string) Header3 (string)
1 data21 data31
2 data22 data32
3 data23 data33
4 data24 data34
5 data25 data35

FilterDT

Header1 (int) Header2 (string) Header3 (string)
4 data24 data34
5 data25 data35

For each row in FilterDT

row(“Header1”).ToString wil lreturn 4 in first iteration

For each row in MainDT
Find index of each row in MainDT where Header1=4 and then use assign to update the values of any column in MainDT

END MainDT

END FilterDT

2 Likes

Hi @jeevith ,

I got your suggestions, but the data in huge amount eg. Weekly i might have 3000 rows so to perform this will take much time using uipath activities.

If you have any idea , how can I achieve this using linq

I’m struggling with syntax if you could provide example that would be better

Hi @NIVED_NAMBIAR

In MainDt there are below column

Invoice no, recipient, customer name, partner name , comment

Need to apply filter on recipient and cust name column and perform some validation on web page and then need to come back and update the values as string in comment column of MainDt

Hi @TUSHAR_DIWASE

Would not be possible to share screenshot for now
Thanks

Hi @Omkar_Deshmukh,

If your datatable is lesser than 8000 rows I dont think you need to worry of optimising robot execution time. You will not save a lot of robot execution time even if you run the automation many times.

I have nothing against Linq, I myself am excited to use it when the situation asks for it. But remember its about getting the things done after asessing tradeoffs. If a Double for loop does it, I dont see any reason to use Linq in this scenario. Agreed that your code base will be shorter to read with linq, but the next developer who gets your code to maintain may or may not be so used to linq either.

@ppr and @Yoichi are ones who can help you with Linq queries.

@jeevith

Already perform this action and its time consuming as compared Linq

anyway, thanks for your suggestions.

Hey @ppr and @Yoichi
can i have your inputs on this?

Would appreciate if you informed the forum users about which approach you would prefer. If you already tried for loops, this should have been mentioned in the question.

This would resolve your issue faster and also trigger the right forum members to answer.

Filter :
Search results for 'filter datatable @ppr ’ - UiPath Community Forum
Search results for 'filter datatable @Yoichi ’ - UiPath Community Forum

@jeevith

will take care from next time.

Well u can filter the datatable and then loop through it

Then inside the loop u are doing a validation right , after the validation u need to update the main dt right

So to update the maindt from the filtered dt

U can use the lookup datatable activity

I hope there would be unique value for each row

Based on that u can update the maindt

Regards

Nived N :robot:

Report_1.xlsx (9.4 KB)

Can you create workflow?

read sheet 1 as mainDT
apply a filter on column G = none and column I = none stored as filterDT

perform some action on filtered data and update the comment column as “performed Action”
update some rows with updated comment in mainDT too

Hi,

Although it might depend on your filter condition, DataView will be better solution because need not to create another filtered datatable.
For example,

dv = New DataView(MainDt,"recipient ='somedata'","",DataViewRowState.CurrentRows)

For Each drv As DAtaRowView In dv
    drv("comment") = "Performed Action"
Next

Then, mainDt will be updated because dv is just view of mainDt.

If you’re concerned about performance, Invoke Code activity (like the above) or LINQ will help you.

Regards,

1 Like

@ppr and @Yoichi

Got something but its not providing comment column values from filterDT

please update attaching xaml and reporLinq_Merge.xaml (15.3 KB)
Report_1.xlsx (9.4 KB)

@ppr @Yoichi

Any update?

Hi,

Can you share your detailed condition and expected result? (Condition of the above is “Contains test”. Is this your requirement? Do you need each filtered datatable and/or just updated MainDT? etc.)
Probably I don’t understand your requirement correctly.

Regards,

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