Hi I have the excel and my required output is the below screenshot. I want Course1 and Course2 in one column and course3 and course4 in one column


Hi I have the excel and my required output is the below screenshot. I want Course1 and Course2 in one column and course3 and course4 in one column

Hi @nikki

Here is a Solution that uses 2 Add Data Row Activities:

Input:

Build Output DT:

The Flow:

The Code in ArrayRow of each Add Data Row activity respectively:

New Object() {CurrentRow("collegeName").ToString, CurrentRow("CourseCode").ToString, CurrentRow("Course1").ToString, CurrentRow("Course3").ToString}
New Object() {"", "", CurrentRow("Course2").ToString, CurrentRow("Course4").ToString}

The Output:

I hope this helps, If this solves your issue do mark it as a solution.
Happy Automation :star_struck:

Can I get the solution as SQL query

Hi @nikki

Here is linq solution

Build a dt_final datatable with the required output columns

dt_final = dt_input.AsEnumerable().SelectMany(Function(x) New DataRow() {
    dt_final.Rows.Add(x("CollegeName").ToString(), x("CourseCode").ToString(), x("Course1").ToString(), x("Course3").ToString()),
    dt_final.Rows.Add("", "", x("Course2").ToString(), x("Course4").ToString())
}).CopyToDataTable()

Sample input and Output

image

Hope this helps

Could you try this:
(It may not work if collegeName or CourseCode is primary key and set to NotNull)

INSERT INTO TableName (collegeName, CourseCode, Course5, Course6)
VALUES 
(CurrentRow("collegeName").ToString, CurrentRow("CourseCode").ToString, CurrentRow("Course1").ToString, CurrentRow("Course3").ToString),
('', '', CurrentRow("Course2").ToString, CurrentRow("Course4").ToString)

hii,use the below linq code in assign activity
Dt_Ouput=(From row In dtInput.AsEnumerable()
Select New Object() {
row(“collegeName”).ToString(),
row(“CourseCode”).ToString(),
String.Join(Environment.NewLine, row(“Course1”).ToString(), row(“Course2”).ToString()).Trim(),
String.Join(Environment.NewLine, row(“Course3”).ToString(), row(“Course4”).ToString()).Trim()
}).CopyToDataTable()

hope this will work!!.