While using .expression in datatable the column is changing


I am using datatable(column).expression in assign activity to give an arithmetic expression (essentially multiplying two columns and storing the value in a third column)

After this assign activity, if I am writing the datatable to excel, my column header of the calcluated column is showing the arithmatic expression and not the column name I wanted

Column name is correct if you look at it, but when I write range to excel, its not the column name that is coming but the dataColumn type that is shown in watch window that is coming up after writing to excel… I do not want the formula in there… there are macros after this step and this whole big column is not appropriate for me
Can someone help, please?


You have to give that column name with add data column activity…

Refer below…This might help you…

Hello Pravin,

I did use add datacolumn and my code is exactly the same as yours… the problem is with values of DailyBookingDT.Columns(11) vs DailyBookingDT.Columns(11).ColumnName

the values for these two expressions are different after we use that .expression assignment

while writing the DT to excel, it’s picking up the value of DailyBookingDT.Columns(11) and that is a problem for me

What are expected values and what is coming currently… I’m a bit confused about the screenshot…
Send me the existing column values(with the column name and index) and what you want in the new column(New Column name and index)…

Hi Pravin

In the image to the left, you see watch window, in there there are two variables encircled

Dt_C9800.Columns(13).columnName and the other is Dt_C9800.Columns(13) One is a string type and the other is a datacolumn type. When writing this Dt_c9800 into excel the datacolumn type is being written in the first row (the place of header) but I wanted the string (columnName) to be writting in excel during writeRange activity.

so in the sequence you have created, if you write the datatable into excel using writerange what do you get for the new added column that has expression?

I am getting to see this when I ran the code you shared earlier

I got your point now…Yes it is coming along with the other columns we are merging…
May be later you can use write cell activity to change the header…As it is fixed position…

I tried Dt.columnName property but it won’t work as we are using expression on that column…

Yeah had to write to excel, then read again and change the column headers… I do not like this approach as it consumes processing … but since my data is not huge it works for now