make_set() / make_list()

make_set() and make_list() are aggregates that collect values into a list (a dynamic array), one list per group:

  • make_set(x) keeps each value once, like distinct inside a group.
  • make_list(x) keeps every value, duplicates included.
SigninLogs
| summarize Countries = make_set(Location) by UserPrincipalName

This gives one row per user, with all the countries they signed in from in one cell, such as ["CZ","DE"]. That is often easier to read than many rows, and it opens up checks on the list itself.

Working with the list

  • array_length(list) returns the number of items. where array_length(Countries) > 1 keeps users seen in more than one country.
  • list[0] reads the first item; wrap it in tostring() to use it as text.

Column names

Unnamed, the columns are called set_x and list_x, for example set_Location.

Things to know

  • The order of the items in the list is not guaranteed.
  • Both functions take an optional second argument, the maximum number of items to keep. Big lists make results hard to read, so collect values from groups you already narrowed down.
  • On this site, make_list() and make_set() accept strings, whole numbers and booleans. Lists of dates are not supported yet; min() and max() often answer the same question.

Examples

1 Every app and country one user signed in with
SigninLogs
| where UserPrincipalName == "jonas.weber@kestrelbay.example"
| summarize Apps = make_set(AppDisplayName), Countries = make_set(Location)
2 Logon types per server, with a count next to them
SecurityEvent
| where EventID == 4624
| summarize LogonTypes = make_set(LogonTypeName), Logons = count() by Computer
3 Keep duplicates with make_list(), and measure the list
DeviceProcessEvents
| where FileName == "cmd.exe"
| summarize Accounts = make_list(AccountName), Unique = make_set(AccountName) by DeviceName
| extend Runs = array_length(Accounts), People = array_length(Unique)

Practice it