Home

Using Lambda to Extend Table

Highlighted
Greg Berns
New Contributor

Using Lambda to Extend Table

I'm trying to move some logic out of the main query into a lambda so the main query is easier to read.

 

 

So I want to take logic like this:

```

T //columns: operation_Name
extend path_Label = iif(operation_Name == '/''home', 'other')
//end up with columns: operation_Name, path_Label
```

And I'd like to move the `iif` logic into a lambda:

```

let translate_path = (operation_Name: string)
{
    iif(operation_Name == '/', 'home', 'other')
};
T //columns: operation_Name
| extend path_Label = invoke translate_path(operation_Name)
```
Also tried:
```
let translate_path = (T:(operation_Name: string))`
{
    T | extend path_Label = iif(operation_Name == '/''home''other')
};
T //columns: operation_Name
invoke translate_path()
```
2 Replies

Re: Using Lambda to Extend Table

Hi,

 

The following query is working for me:

 

let translate_path = (operation_Name:string)
{
    iif(operation_Name == '/', 'home', 'other')
};
AzureActivity
| take 10
| extend path_Label = translate_path(OperationName)

 

Hope it helps,

Meir 

Re: Using Lambda to Extend Table

You can try this in the demo portal

Related Conversations
Yammer Datacenter US/EU
Joseph Demmelmaier in Yammer on
1 Replies
microsoft forms
Mapuleng Koloba in Microsoft Forms on
2 Replies