I am wondering is there a way to remove consecutive duplicates. For example, if we have: [x,y,z,z,z,z, ...]
I want [x,y,z, ...]
| project ClusterName, NodeName, UserName LoadError
| summarize LoadErrorSequence = make_list(LoadError) by ClusterName, NodeName, UserName
| extend LoadErrorSequenceJson = dynamic_to_json(LoadErrorSequence)
| summarize count() by LoadErrorSequenceJson
2
Answers
The other solution is using
index
and it didn't work for large response, I kept getting out of memory/timeout.But
prev
workedAfter getting your dynamic array, you can use the below code to get the required array. I took the same example array as provided by you.
Here first, get the length of the array and use
mv-apply
to loop through the given array’s index. In this, store the current and previous item in columns using the index. After this, filter out the value where the current item is not equal to its previous item. Then, make the array of current item column usingmake_list()
onsummarize
.Output: