Hi Team,
I have a datable table in that table get specific columns to filter values based on the condition and get it count using linq.
Thanks
Shyam
Hi Team,
I have a datable table in that table get specific columns to filter values based on the condition and get it count using linq.
Thanks
Shyam
Here is a sample
d1.asEnumerable.where(Function(x1) CInt(x1(“Sal”))>500).copyToDatatable
D1.Rows.Count or you can use Count function on the Linq itself
Here exactly:
dt.AsEnumerable.Where(Function(x) x(“Column2”).ToString<>Nothing).Copytodatatable.RowCount>0
Sample data table
show in the columns i have get the count from Rep and Item columns
Thanks
Shyam
You have to get row count from Rep item column and also from item column? You want each column count separately.
What filter you want to use?
Hi,
Try here:
dt.AsEnumerable.Count(Function(r) r(“Rep”))
Give a try at
dictGroupCount | Dictionary(Of String, Int32) =
YourDataTableVar.asEnumerable.GroupBy(Function (x) x("Item").toString.Trim).ToDictionary(Function (x) x.Key, Function (x) x.Count)
Hi,
getting on error
refer screen shot
Thanks
Shyam
Hi,
Same error AsEnumerable is not a member of system.Data.Datable
Thanks
Shyam
we didn’t mention this code line
Hi,
i mentioned same error on ur colde
can u tell how to fix it.
Its showing fine here, make sure you are sotring this in a integer variable.
When you put a dot after dt_Excel intellisense sould give you AsEnumerabke in the list automatically, so you donot need to type manually.
Thanks.
Hi @ppr @prateek.mehandiratta9
i able to get overall rows count in the columns : Dt_excel.Columns(“Rep”).Table.RowCount.ToString
i want to specific columns (Rep) get unique item count based the value like if value is Gill the count is 3 to print as output using write line acivity.
Thanks
Shyam
Hi,
Can you share what error you uare getting here, why isnt it working?
dt.AsEnumerable.Count(Function(r) r(“Rep”))
just give a description of the expected output base on the shared input sample
we recommend to avoid communication with too much ping-pongs
Hi,
I want to take the count of “Gill” in the “Rep” column and the same manner in the “item” column i I want to take count of “Desk”.
Columns | Item | Count |
---|---|---|
Rep | Gill | 3 |
Rep | Smith | 1 |
Item | Pencil | 3 |
Item | Binder | 4 |
I need a query to take the count. I belive I have cleared the issue.
Thanks
Shyam
Hi,
Thanks for your Support and help @ppr @prateek.mehandiratta9
i Found the Solution Code running without error. but its showing complier error is present
i thought it is bug. see snapshot
Thanks
Shyam
after AsEnumerable remove brackets.
How do you know its working as solution if its having a compilation error.