Add columns if certain rules are met

Add column
So here if Mumbai chair plastic are same then cost and wood required should get added and so on. Can anyone help me with this

Hi @abhide !
Sure, here is a suggestion that seems to work fine using Linq queries:
Cumulate_numbers.xaml (6.9 KB)

Let us know if it works for you ! :grinning_face_with_smiling_eyes: Don’t forget to change your read range and write range so it fits your filepath and sheetname

1 Like

Thanks a lot @Hiba_B

1 Like

Instead of naming the column if I want to take column index how can it be done ?. I mean instead of city what can i write column(0) ? can you please help


Hi @Hiba_B I used the above data for the operation but i am getting error

Hi @abhide ! Yes you can exchange it by index values.
I have assumed that you treat only with integers. So I changed the conversion + changed with index instead of column names:
image
Here is a suggestion that could work with your case:
Cumulate_numbers.xaml (6.9 KB)

3 Likes


I really appreciate your help. But i am getting above error. Let me attach my excel file so that U can get better idea. Once again i thankyou a lot
comparison.xlsx (36.3 KB)

1 Like

Hi @abhide !
With the real data indeed it’s easier.
The problem is:

  • your data has empty values, that’s why it was not working, so I just added this to work:
    (From d In A_DT.AsEnumerable
    Group d By k=d(0).toString.Trim, l = d(1).ToString, s=d(2).ToString Into grp=Group
    Let gs = grp.Sum(Function (x) CDbl(“0” & x(3).toString))
    Let ms = grp.Sum(Function (x) CDbl(“0” & x(4).tostring))
    Let ra = New Object(){k, l,s,gs,ms}
    Select output_DT.Rows.Add(ra)).CopyToDataTable
  • BUT the data you sent has like 25+ rows so the method that I gave you won’t work: it was for 2 columns.

So here is another suggestion instead:
Cumulate_numbers.xaml (25.4 KB)

It’s not a good one if speaking about performance, but for the Linq approach @ppr might have a better idea for dynamic columns ?

1 Like

@abhide -

This means you have to handle blank or Null rows before applying the query from @Hiba_B

1 Like

Hi @Hiba_B and @prasath17 Thanks a lot both of you for answering my query. I have installed all the required packages


Still i am getting this error

Can you please help me further and if possible send me screen shot of the activity. once again thanks a lot both!!!

Well that’s because we use different versions of Studio. I use 21.4 and you probably use an oldest version.


Can you upgrade ?
If I send you screenshots it will be veeeeery long haha as there are like 20+ activities behind the “Missing activities”

1 Like

Yes thats true. Let me upgrade it on my personal machine and see. Thanks a lot for your input :smiley: :innocent:

1 Like

Hi @Hiba_B mam and @prasath17 sir, the code is running extremely well. I sincerely thank @Hiba_B Mam :relaxed:. The code is taking around 15 min to run for 10 entries. and I actually have 2000 entries in my excel file. Is there any way we can solve this issue. or we can modify excel file before running it in to uipath so the time can be reduced. Eagerly waiting for your inputs :smiley:

That’s indeed the main problem: performance :confused:
To reduce drastically the time, it’s better to use Linq approach. To use it, we need to have static columns.
→ Do you always have exactly the same name columns ? We could try something with it

1 Like

Let me check @Hiba_B Mam i will get back to you thanks for your suggestion

Hi @Hiba_B Mam, can we do this thing as


We have 26 columns we can add two more columns as add first 13 and then add second 13. So we can make use of two columns only and not the columns whose name will keep changing

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