To use the filter option, the headers are not known nor are the position.
We’ll have to find if th data table has yes in it and if so, find the rows and columns of it.
(
From row In dt_Data
Let col = row.ItemArray.Select(Function(x, i) Tuple.Create(x.Tostring.Trim.ToUpper, i)).Where(Function (t) t.Item1.Equals("YES"))
Let colNameArr = col.Select(Function(t) dt_Data.Columns(t.Item2).ColumnName).ToArray
Where col.Count >0
Select dt_Result.Rows.Add({String.Join(", ", row.ItemArray.Take(2).Select(Function(x) x.ToString)), String.Join(", ",colNameArr)})
).CopyToDataTable
dt_Result is a data table which contains two columns Row and Column i.e. the output
Is there a way i can get name of the column and the first values under it.
Ex. The col value is sub1. If there’s a row under the headers and it had value sub11. Then is there a way to extract sub1 & sub11?
(
From row In dt_Data.AsEnumerable().Skip(1)
Let col = row.ItemArray.Select(Function(x, i) Tuple.Create(x.Tostring.Trim.ToUpper, i)).Where(Function (t) t.Item1.Equals("YES"))
Let colNameArr = col.Select(Function(t) dt_Data.Columns(t.Item2).ColumnName).ToArray
Let colNameArr2 = col.Select(Function(t) dt_Data.Rows(0)(t.item2).ToString).ToArray
Where col.Count >0
Select dt_Result.Rows.Add({String.Join(", ", row.ItemArray.Take(2).Select(Function(x) x.ToString)), String.Join(", ",colNameArr.Concat(colNameArr2))})
).CopyToDataTable