I have 3 columns, the first is for the seller, the second is for completing the deal, and the third is for not completing it. I want to know how many deals were made or were not done for each employee through the coordination shown in the picture.
This code give me the total only.
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;
This code give me total data done and not done in ahmed and mark i want to know ahmed only how many text done in dealclosed and how many not done in dealnotclosed support me please