Forum Discussion

DilipDivgi1900's avatar
DilipDivgi1900
Copper Contributor
Feb 01, 2022
Solved

KQL - let statement - get an error : No tabular expression statement found

Whenever I use the "let" as below, get the error : No tabular expression statement found

Trying to figure out what I am doing wrong. 

Can someone throw light on this please?

 

let startTime = ago(1d);
let endTime = now();
let Procdata = (
Perf
| where TimeGenerated between(startTime .. endTime)
| where CounterName == "% Processor Time"
| where ObjectName == "Processor"
| where InstanceName == "_Total"
| summarize PctCpuTime = avg(CounterValue)
by Computer, bin(TimeGenerated, 1h))

 

Thanks

Dilip

  • Change the last lines to:

    by Computer, bin(TimeGenerated, 1h));
    Procdata


    You would get the same result with:

    let startTime = ago(1d);
    let endTime = now();
    Perf
    | where TimeGenerated between(startTime .. endTime)
    | where CounterName == "% Processor Time"
    | where ObjectName == "Processor"
    | where InstanceName == "_Total"
    | summarize PctCpuTime = avg(CounterValue)
    by Computer, bin(TimeGenerated, 1h)

2 Replies

  • Clive_Watson's avatar
    Clive_Watson
    Bronze Contributor

    Change the last lines to:

    by Computer, bin(TimeGenerated, 1h));
    Procdata


    You would get the same result with:

    let startTime = ago(1d);
    let endTime = now();
    Perf
    | where TimeGenerated between(startTime .. endTime)
    | where CounterName == "% Processor Time"
    | where ObjectName == "Processor"
    | where InstanceName == "_Total"
    | summarize PctCpuTime = avg(CounterValue)
    by Computer, bin(TimeGenerated, 1h)