使用 KQL 创建矩阵

Creating a matrix using KQL

这是我在 Databricks 中的一项工作的矩阵。我已经裁剪出任务名称(通常位于矩阵的左侧。绿点显示任务 运行 成功。我想使用 KQL 重新创建它。我有三列数据。时间生成、ActionName(无论是通过还是失败)和 table 名称。我有每个 table 的记录很多个月,但只需要一个 2 周的矩阵。如果有人能提供帮助,非常感谢。

A example of the matrix mentioned above

种类

// Generation of a data sample. Not part of the solution.
let t = materialize (print table_id = range(1,10), dt = range(startofday(ago(20d)), now(), 1d) | mv-expand table_id | mv-expand dt | extend TimeGenerated = todatetime(dt), TableName = strcat("table_",table_id), ActionName  = dynamic(["Passed","Failed"])[toint(rand(2))] | where rand() < 0.9);
// Solution starts here.
t
| extend TimeGenerated = format_datetime (TimeGenerated, 'yyyy-MM-dd')
| evaluate pivot(TimeGenerated, any(iff(ActionName == "Passed", make_string(129001), make_string(128997))), TableName)
TableName 2022-04-01 2022-04-02 2022-04-03 2022-04-04 2022-04-05 2022-04-06 2022-04-07 2022-04-08 2022-04-09 2022-04-10 2022-04-11 2022-04-12 2022-04-13 2022-04-14 2022-04-15 2022-04-16 2022-04-17 2022-04-18 2022-04-19 2022-04-20 2022-04-21
table_1
table_2
table_3
table_4
table_5
table_6
table_7
table_8
table_9
table_10

Fiddle