In this tutorial, we will explore various types of filters we can add to a view.
What you'll create
A group of 5 filters, each of different type and usage.
Importing dates dimension
To be able to use one of the indicator drill blocks -
timeSeries, we have to import the can-dim-dates dimension. You can do that using the
This dimension contains datasets with dates, years, months etc. and is needed for any kind of filtering by date.
To finish the import, use
addMetadata to add all metadata files, and
pushProject to upload the data.
Now we have to link the
transactions dataset to the dimension. Find the
date property of this dataset, and modify it so it contains
foreignKey which points to the
dim_dates dataset. The property should look like this:
The data model should now look like this. You can see that the
transactions dataset is connected to the
globalDate filter controls the main time frame of a project's view. To use it, we need the can-dim-dates dimension we've imported earlier.
Let's add the
filterGroup array with the
globalDate filter on the
transactions.date property to our view.
globalDate filter is different from the other filters. This filter is not listed under the Filters tool icon ( ). Instead, it appears in the top left corner of the application, next to the Project page button and the Granularity drop down.
When you click on the filter, you will get a drop down menu with a calendar where you can select your own date range.
Adding the d
date filter has identical syntax with the
globalDate filter. Its purpose is to be able to filter additional date attributes. Our
transactions dataset is simple, this filter would come to use if we had e.g. date of customer's registration.
date filter will now appear under the Filters tool icon ( ).
indicator filter is used to filter areas based on computed values of indicators on selected granularity.
The usage is pretty straightforward - you specify URI reference to the indicator whose value you would like to filter. In this case, it is
transactions_indicator from the first tutorial. Remember that the referenced indicator (and its metric) must be present in the project.
Note that the indicator filters have their own category in the Filters tool. They also allow you to specify the granularity on which they will be applied to.
histogram filter is used to filter integer or decimal values. We will add a filter on the
This filter uses the same graph as indicator drill's distribution block. The difference is that this graph only has one segment and it can't be turned on/off.
multiSelect filter allows you to filter enumeration types, e.g. days of the week, customer sex, transaction type, etc.
Let's add two
multiSelect filters. The first one will filter the
transactions.day_name property, which contains day names (Monday, Tuesday,... etc.) for each transaction. But since we want the day names to be correct order, we have to specify orderBy property -
day_index which contains integer index of each day.
The second filter will filter the
customers.age_group, which is in correct order by default, so we don't need an extra ordering property. But since this property filters the
customers dataset, it will belong to the "Customers" category.