Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional MultiValue usage in KQL #1617

Closed
rbanks54 opened this issue Sep 13, 2021 · 1 comment
Closed

Optional MultiValue usage in KQL #1617

rbanks54 opened this issue Sep 13, 2021 · 1 comment

Comments

@rbanks54
Copy link

I have a workbook with a global parameter for holding selections made from an initial query table. I then want to use that selection to filter results in a later query.

I also want to default to showing all data when no selection has been made, and only filter when the multi-value parameter is populated.

I've set set the initial query to export it's selection parameters as follows:

image

I see results when I have made a selection, but I can't figure out how to create value KQL when the parameter has no selections, and is a null.

For example:

| where AppService has_any ({AppServices})
is rendered as
| where AppService has_any ()

and similarly something like this to try and work around the null doesn't parse either:
| extend myFilter = iff({AppServices:label} = '<unset>','',{AppServices})
because it's rendered as
| extend myFilter = iff('<unset>' = '<unset>','',)

Basically, I need a value other than :label that won't be nulll when the parameter is unset. Are there any tips for doing this? I can't see anything in the docs that helps me and I can't figure out how to create KQL that will be valid when the the parameter is null.

@gardnerjr
Copy link
Contributor

when a multivalue param has no selected items, it has no rendered value (it is an empty string)

see https://github.com/microsoft/Application-Insights-Workbooks/blob/master/Documentation/Parameters/DropDown.md#special-casing-all

for some examples here, the normal case is to do something like this:

let selection = dynamic([{Selection}]);
SomeQuery 
| where array_length(selection) == 0  // handles no selection being treated as all
    or "*" in (selection)  // handles special case of all=* handled as all
    or  SomeField in (selection) // handles specific selected value matches

converting the selected value into a database array will work with no value there, it ends up being resolved as dynamic([]) which is a valid empty array.

if you're using ADX or Logs, you can do this directly , because they support let. If you're using ARG, where let isn't supported, you'd unfortunately have to possibly do that dynamic([{Selection}] multiple times inside the query text instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants