Make filter options context aware

Hello,

I would like a filter to only show options that will actually yield results, given the other filters set.

For example, I have a visual with user login history. There are a few filters on this such as date range of login, user team, user status etc. and a user name search.

When I set the date range to be the past day, just 10 users are displayed in the list. However, the user control shows all users in the dataset.

How can I make it show only those 10 users in the user name filter control?

If it helps, I’m using S3 as a source.

Many thanks,
Sam

Hello Samellis,

Thanks for reaching out.
For your use case, I recommend implementing cascading controls. See documentation below:

Regards,

Thanks for your reply - unfortunately I don’t think this will work in our case.

Some of the filters are hidden and don’t have controls.

I’ve also tried adding a calculated field but that gives an error when I use a parameter: Expression {{argumentName}} for function {{functionName}} has incorrect argument type {{incorrectArgumentType}}. Function syntax expects {{functionSignature}}.

Calculated field is simply: ifelse({Hierarchy ID} = ${teamParameter}, "Yes", "No")
For comparison, this (without the parameter) gives no error: ifelse({Hierarchy ID} = 5, "Yes", "No")

teamParameter

TYPE

Integer

Default value

0

Dynamic default value

Not set up

Hello @samellis

Are you still working on this or did you find a solution?

Also, is teamParameter a single or multi-value parameter? This is probably where the error is coming from.

Hello @samellis

Were you able to find a solution or do you still need help on this topic?

It has been some time since we have heard from you. If we do not hear from you in the next two business days this topic will be archived.

Hi @duncan

Thanks for your reply - you caught the issue regarding the calculated field, it’s multi-value. This is now kind of working, but I need to prevent “NULL” from showing in the select options. Note: this list is dynamic and I need “select all” to be enabled.

Is this possible? Or is there something else I should return from the calculated field?

ifelse(in({Hierarchy ID},${teamParameter}), {Full Name}, null)

Thanks
Sam

Hey @samellis

How many options are available for users to choose? If it’s not a lot (easy to copy/paste or type a list) you could use “specific values” for your parameter instead of linking it to a field value. That way you can exclude NULL.

@duncan it depends but for some users could be 20k+, and the list changes daily. Perhaps there is a workaround that I’m not considering?

Hey @samellis

In that case I would try return something else in your ifelse like “No data”.

I would also recommend giving the solution in this topic a try:

Thanks @duncan - that worked - I was expecting that custom filter list to remove the options.

I also had to set a default parameter in the analysis, so I could check “Select all”, then remove the default parameter and publish (the parameter is filled by our application when it’s embedded).

A bit of a hack but it works.

It would be good to see a select all option on the filter config always. We’ve also seen its not possible via the UI to configure a filter to select all when there are too many records to display, so we need to update via the API.

Thanks for your help!

1 Like