Format Excel column with new data

Hi, I have this column named “Product Category” and “N.W” as shown below:

I need to add a new column called “NW Elasthane”.

  1. Whenever, “Product Category” contains “… 95% ORGANIC COTTON 5% ELASTHANE” we do 5% of the N.W(0.05*N.W) and paste it in “NW Elasthane”

  2. Whenever, “Product Category” contains “…92% ORGANIC COTTON 8% ELASTHANE” we do 8% of the N.W(0.08*N.W) and paste it in “NW Elasthane”

  3. Whenever, “Product Category” contains “…100% ORGANIC COTTON” we paste 0 in “NW Elasthane”

AFTER:

Can someone help please?
Thanks!
UIPath_Excel_Scratch.xlsx (113.6 KB)

Check your thread.

https://forum.uipath.com/t/add-column-with-data-to-excel/308378

2 Likes

I am doing this:
image

But I am getting this error:
image

@prasath_S Can you help me on this one please mate?

Hi @Yudhisteer_Chintaram1

Could you share the workflow and excel file so i can check from my end…thanks

Your N.W column contains Double Data Type values. Also sometimes this column is empty. So make sure you add assign activity under IF which checks column is not null.

Assuming N.W column is not Double:
row("NW Elasthane") = (CDbl(row("N.W")) * 0.05). ToString

Assuming N.W column is Double:
row("NW Elasthane") = (row("N.W") * 0.05). ToString

1 Like

“IF which checks column is not null.”
What is going to be my condition in the IF statement?
Thanks!

Try row("N.W").ToString <> ""

If suppose you don’t check for empty column values, then NW Elasthane column value be 0.

Not like this?

Yes like this. For “100% ORGANIC COTTON”, you are going to assign NW Elasthane column 0. So here you don’t require If.

Instead of adding Switch inside If, try adding If inside “95% ORGANIC COTTON 5% ELASTHANE” & 92% ORGANIC COTTON 8% ELASTHANE” case.

I am really struggling @Shraddha_Gore .
Could please show me please?

Hi @Yudhisteer_Chintaram1 ,

Add_NW_Elasthane_Column.xaml (13.0 KB)

Here I’ve assigned Double Data Type to NW Elasthane column while adding it to Datatable. As a result, it assigns 0 to empty column values.

1 Like

If you want blank NW Elasthane, then you’ll have to assign N.W Column String datatype.
And Implement If Else like this,

1 Like

Thanks a lot!!!

1 Like

U can find the solution in this workflow
Format_Excel_Column_NewData.xaml (6.6 KB)

Attached the Output file here @Yudhisteer_Chintaram1
UIPath_Excel_Scratch.xlsx (25.6 KB)

1 Like

Thanks a lot!

Welcome,
Please mark as a Solution @Yudhisteer_Chintaram1

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