Help needed with writing new col Excel and DataTable manipulation

Hello,

I have a use case to compare two cols in a excel sheet, then if the 2 columns are equal, then I want to:

*create a new column ( pass/fail) and write a new Excel file with the initial data and the new column.

I have created a workflow(see below) to do it, but my expected result is not valid. I expect to get something like this:

workflow:
WORKFLOW_WITH_ISSUE

expected result
EXPECTED RESULT

but my actual result from my workflow is:
BAD_RESULT

The logic doing the comparison is:


I know I’m missing something in the ELSE part of the IF

Attached is my workflow
assertWithinEXCELColumns (2).zip (20.8 KB)

@Yomi_Oluwadara

You can use this in invoke code by sending dt as in/out…before that make sure to add column as you need
Dt.AsEnumerable.ToList.ForEach(Sub(r) r("NewColumn") = If(r("firststatus").ToString.Equals(r("Secondstatus").ToString),"Pass","Fail"))

Cheers

1 Like

Hi @Yomi_Oluwadara

Try this

(From row In dt.AsEnumerable()
            Let firstStatus = Convert.ToDouble(row("firststatus"))
            Let secondStatus = Convert.ToDouble(row("secondstatus"))
            Let passFail = If(firstStatus = secondStatus, "Pass", "Fail")
            Select dt.Clone().Rows.Add(row("studId"), row("firststatus"), row("secondstatus"), passFail)).CopyToDataTable()

Regards,

1 Like

@Yomi_Oluwadara

(From row In dt.AsEnumerable()
            Let firstStatus = Convert.ToDouble(row("firststatus"))
            Let secondStatus = Convert.ToDouble(row("secondstatus"))
            Let passFail = If(firstStatus = secondStatus, "Pass", "Fail")
            Select dt.Clone().Rows.Add(row("studId"), row("firststatus"), row("secondstatus"), passFail)).CopyToDataTable()

Input:

image

Output:

image

Regards,

1 Like

Hi @Yomi_Oluwadara

I have made the required changes in your flow. Please check the below zip file.
assertWithinEXCELColumns.zip (119.0 KB)

Output:
image

Let me know if you have any queries.

Regards

1 Like

@Anil_G @lrtetala and @vrdabberu Thank you all for the insights. Appreciate it.

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.