我有一个列,它是一个数组,希望打印不同的计数。
Event
| project colorsPresent OutPut
["Red", "Green", "Green", "Red"]
["Yellow", "Yellow", "Yellow", "Yellow"]期望
["Red", "Green", "Green", "Red"] , 2
["Yellow", "Yellow", "Yellow", "Yellow"], 1发布于 2018-03-16 18:56:19
下面是我认为您想要的,使用todynamic、mvexpand和summarize (以及创建输入数据的datatable )
// create your sample data using datatable to make a 'fake' table
datatable (colors: string) [
'["Red", "Green", "Green", "Red"]',
'["Yellow", "Yellow", "Yellow", "Yellow"]'
]
// this part is answering your question
| extend c = todynamic(colors) // turns colors into arrays
| mvexpand c // expands all the values out of colors into their own rows (but each column value is still "dynamic" type)
| extend c = tostring(c) // turn the dynamic c column to strings to summarize the values
| summarize ["Count"] = dcount(c) by colors // count up distinct c values by each row这将输出您在问题中所包含的内容:
colors Count
------------------------------------------------
["Red", "Green", "Green", "Red"] 2
["Yellow", "Yellow", "Yellow", "Yellow"] 1 https://stackoverflow.com/questions/49289845
复制相似问题