Search code examples
azureazure-data-explorerkql

Azure Data Explorer - Projecting columns using parameters


I'm trying use the multi-select parameter to filter displayed columns on my dashboard. I have found multiple separate commands (things like bag-unpack, mv-expand, set_difference and so on), but I don't have enough experience to put them all together. Please help, I'm new.

I've tried Googling different solutions, but I don't know what I don't know, so keyword search hasn't proven fruitful. I wanted to ask the community at StackOverflow for their input.


Solution

  • I had a similar project where I set up a parameter called _columnNames which is a dynamic list of column names in my table. I wanted to plot specified columns relative to time and this could be done using the following code:

    {Table Name}
    | project Time, pa = pack_all()
    | project Time, cols = bag_remove_keys(pa, set_difference(bag_keys(pa), _columnNames))
    | evaluate bag_unpack(cols)
    

    where {Table Name} refers to the table name you ingested in Azure Data Explorer. Hope this helps!