我试图在Azure哨兵的工作簿中构建一个仪表板。其中一列是可变长度的JSON数组。我想拆分这个数组让数组中的每个元素都有自己的一列,但我想不出一个好办法。我想要这个
-----------------------------------
Company | products
-----------------------------------
Apple | [iMac, iPhone, iPad]
Microsoft | [xBox, xBox 360]
Google | [Chromebook]
--------------------------------------
成为
-----------------------------------
Company | product_1 | product_2 | product_3
-----------------------------------
Apple | iMac |iPhone |iPad
Microsoft | xBox |xBox 360 |
Google | Chromebook | |
--------------------------------------
效率不高,但这里有一个选项:
datatable(company:string, products:dynamic)
[
"Apple", dynamic(['iMac', 'iPhone', 'iPad']),
"Microsoft", dynamic(['xBox', 'xBox 360']),
"Google", dynamic(['Chromebook']),
]
| mv-apply with_itemindex=i products on (
extend p = pack(strcat("product_", i+1), products)
| summarize b = make_bag(p)
)
| evaluate bag_unpack(b)
| project-reorder company, product* asc
——比;
| company | product_1 | product_2 | product_3 |
|-----------|------------|-----------|-----------|
| Apple | iMac | iPhone | iPad |
| Microsoft | xBox | xBox 360 | |
| Google | Chromebook | | |