cgsabari
cgsabari

Reputation: 615

How to add two variables values using Kusto query?

I'm new to Kusto query. I've to add two variable values using Kusto query. How to do that.

let c1 = tablename | count;
let c2 = tablename1 | count;
print c1+c2 

the above query is not working

Upvotes: 1

Views: 989

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44941

Your query fails with the following error message:

'project' operator: Failed to resolve scalar expression named 'c1'

This happens since c1 (as well as c2) is a tabular expression and not a scalar.

toscalar() can be used to do the required conversion.

let tablename = StormEvents;
let tablename1 = ConferenceSessions;
let c1 = toscalar(tablename | count);
let c2 = toscalar(tablename1 | count);
print c1+c2
print_0
59116

Fiddle

Upvotes: 2

Related Questions