Hi Everyone,
I need help about my automation problem.
Right now I have the following data below:
As you can see I would like to check if grouping the column Store code and adding sum is possible in UiPath.
Thanks in Advance!
Regards
AA
Hi Everyone,
I need help about my automation problem.
Right now I have the following data below:
As you can see I would like to check if grouping the column Store code and adding sum is possible in UiPath.
Thanks in Advance!
Regards
AA
Hi @aapostol
Welcome to the community.
Follow below steps:
Hi @Surya_Narayana_Korivipadu,
grp.sum(Function...)
I dont see grp
being declared. Do you mean to refer sc
Just wondering how would linq know to refer to a keyword grp
. Is it a reserved keyword in linq, which we can use when grouping?
Should it not be like below?
(From row in dt1.AsEnumerable
Group row by sc = row(“STORE CODE”).ToString()
Let total= sc.sum(Function (x) Convert.ToDouble(x(“CREDIT”).ToString().Replace("$","").Trim()))
Let result = New-Object() {sc(0)(“STORE CODE”),total}
Select dt2.rows.add(result)).CopyToDataTable
How will I encode the linq code?
I am going to do assign activity?
Please give me a sample thank you in advance!
Regards,
AA
Hi @jeevith
From my knowledge, even sc is a temporary variable used to loop through the particular column and group the rows,
We have to assign the grouped rows into a variable by using into grp = Group…now grp (each item will have multiple rows) variable will have the grouped rows
(From row in dt1.AsEnumerable
Group row by sc = row(“STORE CODE”).ToString() into grp = Group
Let total= grp.sum(Function (x) Convert.ToDouble(x(“CREDIT”).ToString().Replace("$","").Trim()))
Let result = New-Object() {grp(0)(“STORE CODE”),total}
Select dt2.rows.add(result)).CopyToDataTable
Thanks
Hi @prasath_S
That is good to know. So grp
has to be declared to be of type Group before we perform operations on it. In into grp = Group I am assuming Group
is a reserved word in linq.
I am learning linq only by reading posts in the community, so wanted to know how this particular query works. Thank you for the explanation.
Hi @jeevith
@prasath_S is correct. I forgot to use into grp=Group
Yes. you should use assign activity.
In the left hand side of assign acitivity you should use dt2, in the right hand side you should use Linq.
Also see below updated linq:
(From row in dt1.AsEnumerable
Group row by sc = row(“STORE CODE”).ToString()
Into grp = Group
Let total= grp.sum(Function (x) Convert.ToDouble(x(“CREDIT”).ToString().Replace(“$”,“”).Trim()))
Let result = New-Object() {grp(0)(“STORE CODE”),total}
Select dt2.rows.add(result)).CopyToDataTable
I missed keyword called Into in the previous reply. Thanks @prasath_S for correcting me.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.