1
votes

I have following user define function

let myFunction = ()
{
T
| where id ==12345
|mv-expand details.data
|extend CreateTime=todatetime(details_data.["time"])
|extend Code=tostring(details_data.code)
|summarize arg_max(CreateTime,Code)
};

Now i want to get the values of each column from above function which returns 1 row with 2 cloumns Something like |print T().CreateTime |print T().Code

Can you please help me achieve the above.

1
Hi Gurdeep, does the answer below answer the question? If yes, please accept it :) If not, please add a comment specifying what you're missing. - Slavik N

1 Answers

0
votes

The toscalar() function will do exactly what you need:

Example:

let SomeResult =
    range n from 1 to 1000 step 1
    | extend r = 100 * rand()
    | summarize min(r), max(r), avg(r);
print toscalar(SomeResult | project min_r)

The result will be:

print_0
0.0437954709718918

Note that accessing a value in a specific column is done using the project operator.