Hi,
How to merge multiple columns to single column
e.g. I want to merge column 3,4,5, 6 untill there is data in that row,
columns might vary , it can be 10 or 20 or 21
but not necessarily data will be in all columns
but merge output should be in column 3, amd merge include 3 onwards .
Hello @1a2bc346dgjk7544ebjkkbvf
Assign activity:
To: dt
Value: (From row In dt.AsEnumerable()
Let mergedValue = String.Join(ββ, row.ItemArray.Skip(2).Select(Function(item) item.ToString()))
Select dt.Rows.Add(mergedValue)).CopyToDataTable()
Thanks & Cheers!!!
Try this
Code:
DT.AsEnumerable().ToList().ForEach(Sub(row)
Dim mergedData = row.ItemArray.Skip(2).
Where(Function(item) Not String.IsNullOrWhiteSpace(item.ToString())).
Select(Function(item) item.ToString()).
Aggregate(Function(current, nextItem) current & ", " & nextItem)
row(2) = mergedData
End Sub)
Please find the below xaml for your reference
BlankProcess12.zip (46.8 KB)
Hope this helps!!
Use this Linq Query
inputDT.AsEnumerable().ToList().ForEach(Sub(row)
row.SetField(βDβ, row(βAβ).ToString() & row(βBβ).ToString() & row(βCβ).ToString()))
Cheersβ¦!
This is working perfectly ! Thanks !!
@lrtetala
Please help me with the code if I want to merge specific col to specific col.
e.g. column 3 to 6 like this . output of merged should be in column 3.
Try this:
DT.AsEnumerable().ToList().ForEach(Sub(row)
Dim columnsToMerge = Enumerable.Range(3, 4)
Dim mergedData = columnsToMerge.
Select(Function(col) row(col).ToString()).
Where(Function(item) Not String.IsNullOrWhiteSpace(item)).
Aggregate(Function(current, nextItem) current & ", " & nextItem)
row(2) = mergedData
End Sub)
Try this
Code:
DT.AsEnumerable().ToList().ForEach(Sub(row)
Dim mergedData = String.Join(", ", row.ItemArray.Skip(2).Take(4).
Select(Function(item) If(Not String.IsNullOrWhiteSpace(item.ToString()), item.ToString(), String.Empty)))
row(2) = mergedData
End Sub)
Please find the below xaml
BlankProcess12.zip (49.1 KB)
Cheers!!
Thanks for your input
Thanks for your input
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.