DataTable numOfCalls2Table = new DataTable(); numOfCalls2Table.Columns.Add("SalesPerson", typeof(string)); numOfCalls2Table.Columns.Add("Scour", typeof(int)); numOfCalls2Table.Columns.Add("Dealclosed", typeof(int)); numOfCalls2Table.Columns.Add("Dealnotclosed", typeof(int)); DataView view = new DataView(table); DataTable distinctValues = view.ToTable(true, "SalesPerson", "Dealclosed", "Dealnotclosed"); if (distinctValues.Rows.Count > 0) { for (int i = 0; i < distinctValues.Rows.Count; i++) { string agentName = distinctValues.Rows[i]["SalesPerson"].ToString(); string dealclosed = distinctValues.Rows[i]["Dealclosed"].ToString(); string dealnotclosed = distinctValues.Rows[i]["Dealnotclosed"].ToString(); DataRow[] agentRows = table.Select($"SalesPerson='{ agentName}'"); DataRow[] dealtyperow = table.Select($"Dealclosed='{ dealclosed}'"); DataRow[] dealtyperow2 = table.Select($"Dealnotclosed='{ dealnotclosed}'"); DataRow newRow = numOfCalls2Table.NewRow(); newRow["SalesPerson"] = agentName; newRow["Scour"] = agentRows.Length; newRow["Dealclosed"] = dealtyperow.Length; newRow["Dealnotclosed"] = dealtyperow2.Length; numOfCalls2Table.Rows.Add(newRow); } } return numOfCalls2Table;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)