1

I have a data table where I can not count on the column names being the same from moment to moment so I cannot build Calculated Columns the standard way because it uses the "Column Name" property (and that can change).

So, I'd like to build them via IronPython using the External Name which won't change without notice.

Keng
  • 52,011
  • 32
  • 81
  • 111

1 Answers1

2

since you already know how to access a particular column by its ExternalName, you can use that method to change a column's Expression property like so:

column.Properties["Expression"] = "If([some_column] = 1, 'YES', 'NO')"
niko
  • 3,946
  • 12
  • 26
  • 1
    but a calculated column doesn't have an externalname....buuuuut, I can use what ever name I give it since it won't change!...perfect! – Keng Nov 05 '15 at 04:20
  • if you're still looping through columns, you could also do something like `my_col_name = column.Properties["Name"] if column.Properties["ExternalName"] is None else column.Properties["ExternalName"]` – niko Nov 05 '15 at 04:26