0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

KustoQuery(KQL)のクエリ結果を定数に変換する方法

Posted at

KustoQuery(KQL)のクエリ結果を定数に変換する方法

KustoQueryのクエリ結果を後続のクエリで定数として扱う方法についてご説明します。

クエリ結果が1行の場合に限定されますが、クエリ全体をtoscalar関数でくくってクエリ結果をスカラー値に変換することで、後続のクエリで定数として扱うことができます。

let Column1Avg = toscalar (
Table1
| where TimeGenerated >= ago(30d)
| summarize Column1Avg = avg(Column1)
| project Column1Avg );
// ここまでで1つめのクエリ結果が Column1Avg という定数に変換されている
Table2
| where TimeGenerated >= ago(1d)
| summarize Column2Avg = avg(Column2)
| summarize Ratio = Column2Avg / Column1Avg
| project Ratio

用途としては、昨日分の全データの平均値が過去30日の全データの平均値と大きくズレていないかのチェックなどがあると思います。

以上、自分のメモがてら記事にしておきました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?