Can someone explain whats going on that code

Hej,

Can someone tell me what going on in that code… I want to undestrand what this grouping do.

TableData.AsEnumerable.GroupBy(Function(item) item(“Type”).ToString).Select(Function(gr) gr.Aggregate(Function(row1, row2) If(CType(row1(“paymentdate”), DateTime) > CType(row2(“paymentdate”), DateTime),row1, row2) ))

Thanks

Hi,

The following expression returns list (IEnumrable) of group by value of the “Type” column.

TableData.AsEnumerable.GroupBy(Function(item) item(“Type”).ToString)

And the following returns row which has the newest date of “paymentdate” in each group.

Select(Function(gr) gr.Aggregate(Function(row1, row2) If(CType(row1(“paymentdate”), DateTime) > CType(row2(“paymentdate”), DateTime),row1, row2) ))

As a result, this expression returns rows which has the newest “paymentdate” for each “Type” as IEnumerable<DataRow>. (Duplicated “Type” row will be removed).

Regards,

Thanks… it gave an idea of how to create group…
But this I can only use is For Each activity…
So now my question is can i do the same thing by using For each row activity and if statements?

Hi,

Alright. How about the following sample?

Sample20210828-1.zip (3.2 KB)

Regards,

Thanks @Yoichi
it helped but i want to check 2 datatable and get the same result out…
how can i do that…

Can you help me with that too…
I have a table which have amount column and have value but when i create a For each … it gives me error
Error: Column ‘Amount’ does not belong to table DataTable.

dt1.AsEnumerable.Where(Function(row) not String.IsNullOrWhiteSpace(row(“Amount”).ToString) AndAlso CType(row(“Amount”), Integer) <> 0).GroupBy(Function(row) dict(row(0).ToString.Trim)).ToArray

Hi,

Can you share specific input data and expected output?

I have a table which have amount column and have value but when i create a For each … it gives me error
Error: Column ‘Amount’ does not belong to table DataTable.

This means dt1 doesn’t have ‘Amount’ column. Can you check dt1 in details?

Regards,

HI yoichi,
do you have an email id where we can talk on that issue or we can connect via teams?
that will be easy to exam for me or I can show you.

I have a system where I have to collect data from 2 table… then i have to also collect data from another system and compair that data together…
I can try to explain…
Data of last month (getting by extract data activity)
Data received through application in system (getting by extract data activity) And
Data to collect from another system.
All data is in system and robot have to compare the data and save the result…
When robot edit the data which is received by application in system … robot has to do compare-
First robot click on edit data… going to 3rd party system and adding data according to current month to that table… (this part is done)
Now robot have to compare if
1 = if last month total amount was in plus - then it has to add those data from last month to current month but only that data which is not in the current month
2 = last month data and this month data with all values is same it has to ignore those data
3 = if data type is same from received application and from 3rd party then it has to delete that data row which has less value.

so it is a complicated compare and im stuck on that.
appericate if you can help or send you id to talk.

hi @Yoichi
kindly help on that please… im waiting for your reply

Hi,

I’m here for share knowledge each other and contribute to our community. So, I’m afraid that basically I reply in just public space like here.
And perhaps you should create new topic if your additional question is apart from this topic’s title, for able to search its solution. Some community member will help you.

Regards,