pweeks_DOIT

Operations Dashboard Category Selector – Change Default Filter with URL Parameter

Blog Post created by pweeks_DOIT on May 18, 2020

This was a weird workaround I devised for having a configurable default filter via URL parameter that wouldn't interfere with a selector's normal usage.

 

I had a category selector filtering elements and I wanted to be able to both select a default option other than first/last, and also be able to use a URL parameter to allow someone to view the dashboard started on a specific category filtered while leaving all other selections available.

 

You can use a URL parameter for filtering of the dashboard elements, but this breaks the category selector since any filters it applies with be AND-ed with your parameter.  You can apply the URL parameter to the category selector directly and this will work to make a link default to a category, but it also breaks the selector since only that category will remain.

The workaround I devised involves creating a new table with your list of categories repeated twice and a second column which is equal to the categories for the first set, and set to the same value for the second.  If you want a default to appear on top without a parameter set, add it a third time with the text default.  Example:

 

Category Name

Workaround

Category 1

Category 1

Category 2

Category 2

Category 3

Category 3

Category 1

All

Category 2

All

Category 3

All

Category 2

Default

 

Now use this table to populate your category selector as grouped values by "Category Name”, sorted by count descending first, then any other sorting desired.  Apply the URL parameter to “Workaround” using contains, and add “All” to your parameter strings.

 

By default, Category 2 has 3 count so it’ll sort to the top with no parameter.  If you give the parameter “cat=Category 3,All”, 3 will have a count of 2 while all others have 1 so that URL parameter sorts to the top as a default while still allowing the remaining ones to be selected.

Outcomes