Need to Generate a sample report?

Input: I have a excel input which contains with different teams
Example:
image
output: should be in another sheet with their counts
image

@SND0912

Try this linq

  1. Read data into datatablt dt
  2. Use build datatable and create 3 columns as needed with string type and dt2 as datatable
  3. Use assign with below
  4. Write back to excel

Dt2 = dt.AsEnumerable.GroupBy(function(x) x(0).ToString).Select(function(x) dt2.LoadDataRow({x.Key,x.Where(function(y) Not String.IsNullOrEmpty(y(1).ToString)).Count.ToString, x.Where(function(y) String.IsNullOrEmpty(y(1).ToString)).Count.ToString},False)).CopyToDatatable

Cheers

Hi Anil
Can I go with for each data table because it is easy to understand.

@SND0912

You can dot hat as well

  1. Assumption is all the value in column 1 are sorted if not first use sort datatable
  2. Then inside loop use if condition to first check if current value and previous value are equal from first column
  3. If equal use one more if to increment either empty total or non empty total
  4. If not that means there is a new value so add the old data to datatable using add data row the value and sums and then initialize sum with 0 and value with new value
    Cheers

siva.xaml (16.1 KB)
@SND0912

Yes we can model a so called groupby case with the help of

  • DataTableVar.DefaultView… and other essential activities
    Have a look here at the the first part, presenting a Non-LINQ approach:

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