2

I am unable to set a scalar date value from a query to a local variable. I get the following error:

SYNTAX ERROR

No tabular expression statement found

Query:

let startTime = toscalar(customMetrics
| where timestamp > ago(1d)
| summarize min(timestamp));

I get a result just fine when running just the query:

Log Analytics results

What am I doing wrong?

Dave New
  • 38,496
  • 59
  • 215
  • 394

1 Answers1

5

You'd need to execute a statement/query with this function, otherwise it's just a function definition that does not get called. The easiest one is print command, but you can also invoke the function within some query:

let startTime = toscalar(customMetrics
| where timestamp > ago(10m)
| summarize min(timestamp));
print startTime
Dmitry Matveev
  • 2,563
  • 11
  • 16