@siddharth bansal Thanks for using Microsoft Q&A forum and posting your query.
Looks like the append syntax is incorrect and resulting in an error. Could you please try below and see if that helps.
let equipment=<query>
|join kind=inner
(Table2)
on $left.LookupId==$right.LookupId
|extend NameEq=strcat(PreFix,".",Value,".",Id)
|project NameEq
;
let inCycle=
Table1
| where Name in (equipment) and Value in ('True','False') and TimeStamp between (datetime(2023-05-24 00:00:00) .. datetime(2023-05-24 23:59:59))
| order by TimeStamp asc
|project Name,TimeStamp,Value,ConnectionDeviceId
|extend KPIValue=iff(Value =='False' and Name ==prev(Name),TimeStamp- prev(TimeStamp),totimespan(0))
|project KPIValue=KPIValue/1s,ConnectionDeviceId,TimeStamp
;
let result=
inCycle
|project Id=new_guid(),ConnectionDeviceId='Device1',KpiName='Uptime',KPIValue,Name='Test',StartDateTime=now(),EndDateTime=now();
TestTable
| set-or-append result
OR
.set-or-replace TestTable <|
let equipment=<query>
|join kind=inner
(Table2)
on $left.LookupId==$right.LookupId
|extend NameEq=strcat(PreFix,".",Value,".",Id)
|project NameEq
;
let inCycle=
Table1
| where Name in (equipment) and Value in ('True','False') and TimeStamp between (datetime(2023-05-24 00:00:00) .. datetime(2023-05-24 23:59:59))
| order by TimeStamp asc
|project Name,TimeStamp,Value,ConnectionDeviceId
|extend KPIValue=iff(Value =='False' and Name ==prev(Name),TimeStamp- prev(TimeStamp),totimespan(0))
|project KPIValue=KPIValue/1s,ConnectionDeviceId,TimeStamp
;
let result=
inCycle
|project Id=new_guid(),ConnectionDeviceId='Device1',KpiName='Uptime',KPIValue,Name='Test',StartDateTime=now(),EndDateTime=now();
TestTable
| union result
If you use .append
command, then the query will fail if the table doesn't exist. doesn't exist. Whereas if you use .set-or-replace
or .set-or-append
table will be created if it doesn't exist.
For more info please refer to this document: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/management/data-ingestion/ingest-from-query
Hope this helps.
Please don’t forget to Accept Answer
and Yes
for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.