Search code examples
arraysazure-data-explorerkql

Is it possible to compare a value against an array of values in Kusto?


Is it possible to compare a value against an array of values in Kusto?

I can do the check like this:

letters
| where letter == "A" or letter == "B" or letter == "C"

But since I have to add and remove the characters (and sometimes there are up to 10 characters) so often it gets tiresome to type out the whole or letter == "{some letter}" every time.

Is there a construct like the following in Kusto:

letters
| where ["A", "B", "C"] contains letter

?

A mere googling did not give any results. I guess it is because I do not know what the construct is called, so my Google searches miss the correct results.


Solution

  • dynamic data type

    let letters = datatable(letter:string)["C", "O", "B", "R", "A", "-", "K", "A", "I"];
    letters
    | where letter in (dynamic(["A", "B", "C"]))
    
    letter
    C
    B
    A
    A

    Fiddle