Reputation: 1132
I would like to dynamically name the calculated column, like this:
.create-or-alter function ToNewName(T:(Id:string), columnName: string)
{
T | extend columnName = Id
}
However, this create a new column called columnName
instead. How do I make the second columnName
link to the parameter?
Upvotes: 1
Views: 916
Reputation: 193
You can use column_ifexists
StormEvents | project column_ifexists("Capital", State)
See here:
https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/column-ifexists-function
Upvotes: 0
Reputation: 7618
There is no built in support for this in the language, however here is a possible workaround:
let foo = (p:string)
{
print z=pack(p, 1)
| evaluate bag_unpack(z)
};
foo('this is a run-time column name')
Upvotes: 1