Creating and using filters

There are plenty of times when we want to narrow our focus on certain things in our view. This can be achieved by filtering the unnecessary data points. For example, we may have some products which are loss making and we want to focus only on those products or there are certain types of products that we want to use for our analysis. In such situations, we will use Filters in Tableau. We have a Filters shelf in Tableau and anything that needs to be filtered out will be placed on that shelf.

Let us see an example where we filter out the data.

Getting ready

For the following recipe, we will continue working in our existing Tableau workbook and we will now switch back to our Orders data from the Sample - Superstore.xlsx dataset.

How to do it…

  1. Let us make sure that you have selected the Orders (Sample - Superstore) data source in the Data window. Once you've done that, create a new sheet and rename it to Filters.
  2. Let us then drag Sub-Category from the Dimensions pane and drop it into the Columns shelf followed by dragging Sales from Measures pane and dropping it into the Rows shelf.
  3. Once we have done that, we will get a bar chart. Next, let us drag the Sub-Category from the Dimensions pane again and this time drop it into the Filter shelf. We will get a pop up window as shown in the following image:
    How to do it…
  4. There are multiple tabs that are visible and we will continue with the General tab. From the list that is displayed, we will uncheck the first 2 Sub-Categories, that is, Accessories and Appliances. Clicking on OK will give us 15 Sub-Categories instead of the previously shown 17 Sub-Categories.
  5. Next, let us drag Profit from the Measures pane and drop it into the Filter shelf. We will get a dialog box as shown in the following image where Tableau is primarily asking us about the aggregation that we want to filter, earning, do we want to filter Sum of Profit or Average of Profit and so on:
    How to do it…
  6. We will select the Sum option and then click on the At Least tab and type 0 in the type in box. Refer to the following image:
    How to do it…
  7. Keeping the rest of selection as it is, we will click OK. Once we do that, we will see that there are only 12 Sub-Categories out of the already filtered 15 Sub-Categories that are having positive Profit whereas the excluded Sub-Categories are loss making. Refer to the following image:
    How to do it…
  8. Using the preceding steps, we have now filtered the data but the end user doesn't have any control over changing the filters. For example, right now, we have filtered out the Sub-Categories that have negative Profit. However, our end user may only be interested in the loss making Sub-Categories. Thus, we need to give the flexibility to change the filter to the end user and to do so, we need to show the filter to the end user by clicking on the dropdown arrow of Sub-Category in the Filter shelf and selecting the option which says Show Filter. Let us do the same for SUM(Profit) in the Filter shelf. Refer to the following image:
    How to do it…
  9. Currently the filter is a multi-select filter and a slider. We can change these by clicking on the dropdown arrow for the Filter and selecting from the various options available. Refer to the following image:
    How to do it…

How it works…

Once we show the filter to the end user, the end user can change the filters and slice and dice the data as required. Further, in the preceding recipe, we saw that the way Tableau works with Dimensions on the Filter shelf versus Measures on the Filter shelf is very different and hence the options that we get when we drop a Dimensions on a Filter shelf will vary as against the options that we get when we drop a Measure on the Filter shelf.

Even though dates are referred to as Dimensions, they are special Dimensions and when called on the Filter shelf, the options will appear as shown in the following image:

How it works…

The filters that we have created are restricted to the current worksheet and are at times referred to as Local filters. In the upcoming chapters, we will see how we can extend these filters to affect multiple worksheets on a Dashboard or even across the entire data source or multiple data sources.

Another way of filtering data is by selecting multiple marks from the view and selecting either the Keep Only or Exclude option from the Tooltip. Refer to the following image:

How it works…

There is a lot more to filtering in Tableau and to read more about Filters, refer to https://onlinehelp.tableau.com/current/pro/desktop/en-us/filtering.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.76.204