Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
501 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In ADX , I have a table with a column named 'Names' that contains values like the following:
Names |
---|
["Name1","Name2"] |
[""] |
["Name1"] |
["Name3"] |
I need to create a new column that combines the values of each row without duplicates. The desired output is:
Names | CombinedNames |
---|---|
["Name1","Name2"] | ["Name1","Name2"] |
[""] | ["Name1","Name2"] |
["Name1"] | ["Name1","Name2"] |
["Name3"] | ["Name1","Name2", "Name3"] |
How can I achieve this in KQL (Azure)?
Hi @Manuprasad M N ,
To accomplish you need several Kusto functions:
This will result in the query below:
datatable (MyData:dynamic )
[dynamic(["Name1","Name2"]),
dynamic([""]),
dynamic(["Name1"]),
dynamic(["Name3"])]
| serialize
| scan declare (data_combined_and_filtered: dynamic=dynamic(null)) with
(
//combine and sort the array
step s1: true => data_combined_and_filtered = array_sort_asc(set_union(MyData, s1.data_combined_and_filtered));
)
//remove empty strings
| mv-apply data_combined_and_filtered on (
summarize value = make_list_if(data_combined_and_filtered, isnotempty(data_combined_and_filtered))
)
Hope this will help.
Kind Regards,
Wilko
Please do not forget to "Accept the answer” wherever the information provided helps you, this can be beneficial to other community members. If you have extra questions about this answer, please click "Comment".