top x filtering with two dimensions_ using a parameter for dynamic nested filtering

15
4/ 15/2016 T abl eau Ti p: Usi ng a parameter for dynamic nested f i l teri ng ht tp: //vi zwiz.bl ogspot.in/2012/ 07/tableau-tip-usi ng-parameter-for-dynamic.html 1/15 VizWiz Data Viz Done Right  dynamic , filter , nested ,  parameters , sort , table calc , tableau  3 comments Suppose you have two dimensions, Customer Segment and Product Sub-Category, and you are displaying sales for each in a bar chart like this: Y ou want to look at only the top X Pr oduct Sub-Categories within each Cus tomer Segment based on Sales. Naturally , you click on the Sort Descending button, but, uh oh, you get this: Tableau Tip: Using a parameter for dynamic nested filtering

Upload: srikanthm44

Post on 06-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 1/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html

VizWizData Viz Done Right

 dynamic , filter , nested , parameters , sort , table calc , tableau  3 comments

Suppose you have two dimensions, Customer Segment and Product Sub-Category, and you are displaying sales for each in a bar chart like this:

You want to look at only the top X Pr oduct Sub-Categories within each Customer Segment based on Sales. Naturally, you click on the Sort

Descending button, but, uh oh, you get this:

Tableau Tip: Using a parameter for dynamic nested filtering

Page 2: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 2/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 2

What happened? The bars are not sorted by Product Sub-Category within  each Customer Segment. They’re actually sorted by the total   of the

Product Sub-Category across the entire table.

What we really want is for the Product Sub-Categories to be sorted within each Customer Segment. To do that, you need to create a set.

Step 1 – Choose the two fields you want to create the set with, then right-click and choose Create Set.

Page 3: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 3/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 3

Step 2 – Give the set a name if you want, rearrange them to the proper order and click ok.

 NOTE: If the columns are not in the order you want, then simply drag them lef t and/or r ight. In our example, we want Customer Segment f irst

 because that is our first level dimension.

Step 3 – Drag your new set into the view by placing it between the Customer Segment and Product Sub-Category dimensions on the Rows shelf.

Step 4 – Clear the sort from the Pr oduct Sub-Category dimension, then right-click on the Set on the Rows shelf and choose Sort. Set the sort order to

descending by Sales.

Page 4: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 4/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 4

Your chart is now sorted by Product Sub-Category within each Customer Segment.

Page 5: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 5/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 5

Step 5 – Clean up the chart by right-clicking on your set in the Rows shelf and uncheck Show Header.

That still leaves some extra grid lines. To clean them up go to the menu and choose Format => Borders. Move the slider on the Row Divider level

one spot to the left.

Page 6: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 6/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 6

You should now have a nice clean bar chart.

But, I want to see only the top X Product Sub-Categories within each Customer Segment. Let’s continue on.

Step 6 – Create a parameter to allow the user to choose between the top 1 and the top 10.

Step 7 – Create a “rank” field that will show you the rank of each Product Sub-Category within each Customer Segment.

Page 7: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 7/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 7

Step 8 – Add the Rank measure to the Level of Detail shelf.

Step 9 – Edit the Rank field by right- clicking on the Rank field and choosing Edit Table Calculation. Choose Advanced  from the Computing using

list.

In the Advanced window, move both f ields into the Compute Using box and change the Order Along section to Sales descending. Click OK.

Page 8: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 8/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 8

 Now updated the Rank table calculation to the f ollowing:

Basically what this is saying is that the Rank field should compute for each Product Sub-Category within a Customer Segment, then it should restart

counting when it gets to the next Customer Segment.

Step 10 – Create a calculated field that uses the Top X parameter to filter the number of Product Sub-Categories that should be displayed within each

Customer Segment.

Page 9: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 9/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 9

This creates a true/false filter.

Step 11 – Add the Top X ? true/false calculated field to the Filter shelf and select True.

Step 12 – Show the Top X parameter control created in Step 6 and you’re done!

Page 10: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 10/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 10

You can now use the Top X control to pick how many Product Sub-Categories you want to show within each Customer Segment.

Download the Tableau Workbook here.

Tableau Tip Tuesday: How

to Create ...

Tableau Tip Tuesday:

Creating a Cha...

Tableau Tip: Conditional

Axis Forma...

The Sleeping Habits of 

Tableau Zen ...

Tableau Tip: Month over 

Month KPI M...

3 comments :

Santiago Restrepo  July 18, 2012 at 1:54 PM

Related Posts

Page 11: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 11/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 1

Reply

Andy,

Great posting.

Another option is to place the Rank field in a quickfilter. This way, steps 10 to 12 are not required.

I posted a similar workbook here:

http://public.tableausoftware.com/views/RankWithinPartition/RankWithinPartition?:embed=y

Thanks!

Reply

Thanks Santiago! This is exactly what I love about my blog and Tableau. There are always people that can help make you better.

We don't exactly get rid of the three steps, but we definitely wouldn't need the parameter.

As additional information for others:

1. Remove the parameter and true/false filters from the worksheet.

2. CTRL+Drag the Rank field from the Level of Detail shelf to the Filters shelf. CTRL+Click maintains the special calculations I added

in step 9.

3. Show the quick filter for Rank 

4. Change it to "At Most" and make sure it's a slider.

I've updated the workbook that is linked at the bottom of the post with Santiago's suggestions.

Andy Kriebel  July 18, 2012 at 4:34 PM   MOD

Additionally, you do not need the Set pill on the worksheet. When you use the Advanced Compute using, and move multiple pills to the

right-side list box, you are making a Set there, and the Set pill on the worksheet is now redundant. Also, in the Edit Table Calculation

dialog, you do not need to set the At The Level option, you can leave it at Deepest (not a big deal, but it saves some clicks). To get the

visual nested sorting without the Set pill, use the Rank pill as a discrete on the Rows shelf. You also have a few extra redundant pills that I

cleaned up as well, see http://public.tableausoftware.com/views/TopXFilteringwithTwoDimensions_0/AltwithoutSet  for my edits.

Alternatively, you can use the Set, and a copy of Customer Segment field. This way you can skip the advanced dialog, and just set thecompute using to the Set pill from the right-click context menu (saving even more clicks). I included this as another tab in the workbook.

Like you said, there are multiple ways to accomplish things. I would recommend choosing one route instead of trying to do both at the

same time.

One of the minor advantages of using just the Set without the advanced, is the sort button that Tableau adds to the axis is now usable,

with a click you can get Top-N, Bottom-N, or no sort (with no-sort not really useful), same functionality could be added using a

 parameter and calc field as well, just wanted to point out the minor detail.

If you want to take this to the next level, try making a Top-N with Other, or the super-tricky have the bars be stacked bars, and see the

added unexpected complexities when not all possible dimension combinations exist.

Joe Mako  July 18, 2012 at 6:08 PM

Page 12: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 12/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 12

Add comment

Enter your comment...

Comment as:  Google Accou

Publish 

Preview

Reply

Search

SEARCH

Andy KriebelHead Coach at The Information Lab

Tableau Zen Master

Tableau Certified Trainer

Data Viz Guru

Story TellerData Rockstar

Love Tableau? Love data viz? Like my Facebook page and follow my blogs:

 VizWiz & Data Viz Done Right.

 

ABOUT ME

Page 13: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 13/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 13

 

SUBSCRIBE TO

  Posts

 Comments

The Greatest Tableau Tip EVER: Exporting CSV made simple!

Tableau Tip: How to make KPI donut charts

Tableau Tip: 7 easy steps to create a combination chart with overlapping bars & a line

Tableau Tip: Using the TOTAL function to summarize dimensions

Excel: How to create a dual axis chart with overlapping bars and a line

Tableau Tip: Displaying multiple, disparate measures on multiple rows

Create a global filter in Tableau across multiple data sources in eight simple steps

Makeover Monday: From WTF to Wow!

Tableau Tip: How To Create a 100 Mark Unit Chart inside of a Tooltip

Makeover Monday: Women's Rights Around the World - An Interactive Graphic

POPULAR POSTS

Page 14: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 14/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

http://vizwiz.blogspot.in/2012/07/tableau-tip-using-parameter-for-dynamic.html 14

Follow Andy Kriebel's board Data Viz on Pinterest.

DATA VIZ FAVORITES

Baseball Reference

Batch Geocoding

City Population Stats

Color Blindess Simulator 

Color Brewer 

Data.gov

FRED

Football (Soccer) Facts

Google Fusion Tables

IconMoon App

OData Producers

USEFUL REFERENCES

► 2016 (51)

► 2015 (150)

► 2014 (70)

► 2013 (63)

▼ 2012 (67)

► December (4)

►  November (4)

► October (4)

► September (5)

► August (7)

▼ July (6)

Tableau Tip: Dynamic axis selections with paramete...

Tableau Tip: Using the TOTAL function to summarize...

Tableau Tip: Adding totals of a 2nd measure on top...

Maybe it’s Nielsen’s fan chart that is causing con...

Tableau Tip: Using a parameter for dynamic nested ...

Tableau Tip: I’ll take you to the candy shop. I’ll...

► June (4)

► May (7)

► April (8)

► March (6)

► February (8)

BLOG ARCHIVE

Page 15: Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

8/18/2019 Top X Filtering With Two Dimensions_ Using a Parameter for Dynamic Nested Filtering

http://slidepdf.com/reader/full/top-x-filtering-with-two-dimensions-using-a-parameter-for-dynamic-nested-filtering 15/15

4/15/2016 Tableau Tip: Using a parameter for dynamic nested filtering

© VizWiz 2009. Powered by Blogger . Blogger templates . Social Networking Scripts . Posts RSS . Comments RSS

► January (4)

► 2011 (105)

► 2010 (71)

► 2009 (32)

 2,492,382

TOTAL PAGEVIEWS

 

VISITORS