How to count with LINQ

hi,

(
From row In dt
Group row By a = row(“xx”) Into grp = Group
Let xSum = grp.Sum(Function(x) CDbl(x(“xx”).ToString.Trim))
Select dt.Rows.Add({a,xSum})
).CopyToDataTable

This code collection is being done. How to continue counting

1 Like

@Onur_Oz

(
From row In dt
Group row By a = row(“xx”) Into grp = Group
Let xSum = grp.Sum(Function(x) CDbl(x(“xx”).ToString.Trim))
Select dt.Rows.Add({a,xSum a.count})
).CopyToDataTable

Try by passing a.count

It will give count in another column

If you want to get the count of rows from this linq first save the above expression in a datatable variable using assign activity

dt_output = your above expression

Where dt_output is a variable of type datatable and is defined with default value as New System.Data.Datatable in variable panel itself

If you want to use this datatable further you can use further for any calculation

To just get row count, use a assign activity like this

int_rowcount = dt_output.Rows.Count

Where int_rowcount is a variable of type integer

To know further functionality or calculation on datatable refer this thread

Hope this clarifies

Cheers @Onur_Oz

1 Like

Hope it’s clarified @Onur_Oz
If yes Forum FAQ - How to mark a post as a solution