Get scalar value from table in Kusto, KQL

7.9k Views Asked by At

I am trying to get the maximum of a column from a table and get the output of the data in the form of a scalar to be used in another table. I am attaching a sample code for reference here.

Covid19
| limit 10
| summarize (max(Confirmed)) 

This gives me an output as in the following image: Result of Above Query

Now I want to get the value of the result as a scalar. I am new at KQL so maybe my approach as a whole can also be wrong any help will be appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

You could use toscalar() as part of a let statement.

For example:

let maxConfirmed = toscalar(
   Covid19
   | limit 10
   | summarize max(Confirmed)
);
... do something with 'maxConfirmed' ...