Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
UncleRiotous
Creator
Creator

Set A Filter in Code

I've been asked to create a bookmarked filter in an app that will automatically show the user his team's stats but allow for them to filter to other teams if they want. I want users to open the app and see just the values for their team (regardless of which team they belong to) but have the option to expand or change that selection after that.

I can identify the user's details automatically but I'm struggling to find a way to apply a filter. What I want is the opposite of GetCurrentSelections so that I can set the current selections, preferably with a variable. It doesn't look as though that is available unfortunately.

Section Access won't work because I need users to have the option to expand their selection beyond the initial selection.

I know I could apply a variable (controlled by a toggle switch) to the set analysis of every visualisation but that seems like a bad solution.

Any suggestions for a way to achieve this?

Labels (1)
1 Solution

Accepted Solutions
GaryGiles
Specialist
Specialist

If you are using the Qlik Sense April 2020 release or later, you could set a sheet action on the default sheet of the application to preselect the teams for the User.  This would require that you can associated the results of OSUser() to the appropriate teams.  You can find this option under the Sheet properties - Action panel.

View solution in original post

2 Replies
GaryGiles
Specialist
Specialist

If you are using the Qlik Sense April 2020 release or later, you could set a sheet action on the default sheet of the application to preselect the teams for the User.  This would require that you can associated the results of OSUser() to the appropriate teams.  You can find this option under the Sheet properties - Action panel.

UncleRiotous
Creator
Creator
Author

Thanks Gary, that's let me do exactly what I needed to do.

For the record I set a variable (vLoadCount) to 1 and then used the following expression in the sheet action to "Select values in a field".

=If($(vLoadCount)=1,
Aggr(only(
{<
GROUP={'$(vUserGroup)'}
>}Patch))
,
GetFieldSelections(Patch,';',100)
)

Then I set up a second action to "Set variable value" to change vLoadCount to 0 therefore only setting the default when the user first accesses the sheet.