Monday, January 28, 2013

Working with Filters in Tableau


Today, we will look at how to create filters in Tableau.  Filters allow you to control the data that is displayed in your graphs.  As usual, we will use the Superstore Sales sample data set in Tableau.

Step 1:

  • Create a Worksheet
Average Discount by Region
Let's say that we are the new manager for the South and East Regions, so we only want to see these only the graph.  We can accomplish this with a filter

Step 2:

  • Right-Click "Region" in the Rows Pane and Select "Filter"
  • Under the "General" Tab, Uncheck the boxes for "Central" and "West"
Average Discount by Region (South and East)
On the other hand, let's say we only want to see the Regions that end in "st", which in this case are East and West.  We can do that too.

Step 3:

  • Drag "Region" off of the Filters Pane to remove the filter.
  • Right-Click "Region" and Select "Filter"
  • Under the "Wildcard" Tab, Select the "Ends With" Bubble.
  • Type "st" in the Match Value Box.
Average Discount by Region (Ending in "st")
Now, what if we only wanted Regions that have an average discount of less than 5%.  That is just as simple

Step 4:
  • Remove the "Region" filter.
  • Open the filter window again for "Region"
  • Under the "Condition" Tab, Select the "By Field" Bubble
  • In the "Field" Box, Select "Discount"
  • In the "Aggregation" Box, Select "Average"
  • In the "Operator" Box, Select "<"
  • In the "Value" Box, Type ".05"
Average Discount by Region (Less than 5%)
You may notice that we added another decimal place to the Discount Field to clarify that the values were in fact less than 5%.  This will be explained in a later post.  Finally, what if you only wanted to see the top 2 Regions?

Step 5:
  • Clear the filters and reopen the filter window for "Region"
  • Under the "Top" Tab, Select the "By Field" Bubble
  • In the "Direction" Box, Select "Top"
  • In the "Number" Box, Type "2"
  • In the "Field" Box, Select "Discount"
  • In the "Aggregation" Box, Select "Average"
Average Discount by Region (Top 2)
There are a myriad of possibilities when it comes to way you can filter your data in Tableau.  Don't be afraid to mess around and see what kinds of interesting ways you can discover.  Thanks for reading.

Brad Llewellyn
Associate Consultant
Mariner, LLC
llewellyn.wb@gmail.com
https://www.linkedin.com/in/bradllewellyn

5 comments:

  1. How do you combine different filters? In your step 3 example, how would I select the regions that ends with "ST" OR start with "S"?

    ReplyDelete
    Replies
    1. Popolito,

      Thanks for commenting! The easiest way to take care of that kind of situation is with a calculated field. For instance, if you create a calculated field "Region Filter" with the calculation

      RIGHT( [Region], 2 ) = "ST"
      OR
      LEFT( [Region], 1 ) = "S"

      You can take this calculated field and put it on the filters shelf. Then, you can filter on True. This should achieve what you want.

      Delete
    2. Brilliant! Thank you! I was struggling with the syntax of the formula in the filter condition tab, which is not well documented...

      Delete
    3. Note also teh function STARTSWITH and ENDSWIDTH which could be used in that example, pretty convenient too...

      Delete
    4. You're right! So many useful functions. Glad you could work it out.

      Delete