Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Top N and bottom N view on the same worksheet In Tableau

  1. 1. Ranga Naik Top N and Bottom N View on the Same Worksheet This article helps you find the top and bottom N within the whole data set, Here, we will create two side bar graphs in same work sheet, one is showing Top N values and the other is showing Bottom N values .We Can achieve this one more than 5 methods . In real time Every dashboard or chart created needs to support one common business question What are the Top customers or products Or Players (it can be anything Region , country , state level , city level etc) . Steps to get Top N Bottom N view on the same worksheet: Let’s use any data source example excel, csv or any database tables. I am going to use superstore data source. Once you connected to data Follow the below steps Method 1: Using Set Most of the tableau developer aware about this method, but for beginner it will helpful. Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf. Step 2 : Create Top N and Bottom N parameter that will allow users to choose different Values. In my example I am going to create Top 5 and Bottom 5 selection parameter
  2. 2. Ranga Naik Step 3: Right Click on “Sub-Category” dimension present at the data pane section and then select Create -> set Step 4 : Create a Set and name it as Top N Category. Go to the Top filter tab -> Select By field -> Choose the parameter what you created i.e Top N and Bottom N parameter.
  3. 3. Ranga Naik Step 5: Create one more set and name it as Bottom N Category follow above step instead of “top” choose bottom Step 6: Now you have two sets, one for the TOP N VALUE and one for the BOTTOM N VALUE. Select both sets > right-click > Create Combined Set
  4. 4. Ranga Naik Step 7: Give Name as Top N and Bottom N combined set and choose All members in both sets. Step 8: Now you can drag this new set “Top N and Bottom N combined set ” to the Filter shelf and you can able to see your desired result. Sort it descending order, Enable show mark label and choose show parameter control
  5. 5. Ranga Naik Method 2: Using Index (), Size () function Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf. Step 2 : Sort the sub category data to descending order Click sub category from column shelf -> select sort -> choose sort order i.e Descending -> Choose Sort By ( On which filed you want to short ) -> choose aggregation
  6. 6. Ranga Naik Step 3: Create calculated filed i.e Top N and Bottom N and use parameter what you created in method 1 In Calculation Mention any one of the formula i.e a or b a) INDEX() <= [Top N and Bottom N Parameter] OR INDEX() >= Size() - [Top N and Bottom N Parameter]
  7. 7. Ranga Naik b) INDEX() <= [Top N and Bottom N Parameter] OR [Top N and Bottom N Parameter] > Size() - INDEX() Step 4: Drag calculated field into filter shelf and choose “TRUE”
  8. 8. Ranga Naik Step 5: Enable the parameter and Label you will get desired result in a Single view. Method 3: Using First(), Size () function Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf. Step 2: Sort the sub category data to descending order Click sub category from column shelf -> select sort -> choose sort order i.e. Descending -> Choose Sort By (On which filed you want to short) -> choose aggregation
  9. 9. Ranga Naik Step 3: Create calculated filed i.e Top N and Bottom N_first and use parameter what you created in method 1 In Calculation Mention any one of the formula i.e a or b a) -First() < [Top N and Bottom N parameter ] OR -First() >= Size() - [Top N and Bottom N parameter ]
  10. 10. Ranga Naik b) -First() <[Top N and Bottom N parameter] OR [TopN and BottomN parameter] >= Size() +First() Step 4: Drag calculated field into filter shelf and choose “TRUE”
  11. 11. Ranga Naik Step 5: Enable the parameter and Label you will get desired result in a Single view. Method 4: Using Last (), Size () function Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf. Step 2: Sort the sub category data to descending order Click sub category from column shelf -> select sort -> choose sort order i.e. Descending -> Choose Sort By (On which filed you want to short) -> choose aggregation
  12. 12. Ranga Naik Step 3: Create calculated filed i.e Top N and Bottom N_last and use parameter what you created in method 1 In Calculation Mention any one of the formula i.e a or b a) LAST() >= Size() - [Top N and Bottom N parameter ] OR LAST () < [Top N and Bottom N parameter ]
  13. 13. Ranga Naik b) [Top N and Bottom N parameter ] >= Size() - LAST() OR LAST () < [Top N and Bottom N parameter ] Step 4: Drag calculated field into filter shelf and choose “TRUE”
  14. 14. Ranga Naik Step 5: Enable the parameter and Label you will get desired result in a Single view. Method 5: First() , LAST() Function Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf. Step 2: Sort the sub category data to descending order Click sub category from column shelf -> select sort -> choose sort order i.e. Descending -> Choose Sort By (On which filed you want to short) -> choose aggregation
  15. 15. Ranga Naik Step 3: Create calculated filed i.e Top N and Bottom N_first_last and use parameter what you created in method 1 In Calculation Mention below formula i.e -FIRST() < [Top N and Bottom N parameter ] OR LAST () < [Top N and Bottom N parameter ]
  16. 16. Ranga Naik Step 4: Drag calculated field into filter shelf and choose “TRUE” Step 5: Enable the parameter and Label you will get desired result in a Single view.
  17. 17. Ranga Naik Method 6: Rank_Unique () , size() Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf. Step 2: Sort the sub category data to descending order Click sub category from column shelf -> select sort -> choose sort order i.e. Descending -> Choose Sort By (On which filed you want to short) -> choose aggregation Step 3: Create calculated filed i.e Top N and Bottom N_Rank_unique and use parameter what you created in method 1 In Calculation Mention any one of the formula i.e a or b a) RANK_UNIQUE(SUM([Sales])) <= [Top N and Bottom N parameter ] OR RANK_UNIQUE(SUM([Sales])) > size() -[Top N and Bottom N parameter ]
  18. 18. Ranga Naik b) RANK_UNIQUE(SUM([Sales])) <= [Top N and Bottom N parameter ] OR [Top N and Bottom N parameter ] > size() -RANK_UNIQUE(SUM([Sales])) Step 4: Drag calculated field into filter shelf and choose “TRUE”
  19. 19. Ranga Naik Step 5: Enable the parameter and Label you will get desired result in a Single view.
  20. 20. Ranga Naik Method 7: Rank () , size() Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf. Step 2: Sort the sub category data to descending order Click sub category from column shelf -> select sort -> choose sort order i.e. Descending -> Choose Sort By (On which filed you want to short) -> choose aggregation Step 3: Create calculated filed i.e Top N and Bottom N_Rank and use parameter what you created in method 1 In Calculation Mention any one of the formula i.e. a or b a) RANK(SUM([Sales])) <= [Top N and Bottom N parameter ] OR RANK(SUM([Sales])) > SIZE() - [Top N and Bottom N parameter ]
  21. 21. Ranga Naik b) RANK(SUM([Sales])) <= [Top N and Bottom N parameter ] OR [Top N and Bottom N parameter ] > SIZE() - RANK(SUM([Sales])) Step 4: Drag calculated field into filter shelf and choose “TRUE”
  22. 22. Ranga Naik Step 5: Enable the parameter and Label you will get desired result in a Single view. Method 8: Rank_DENSE () , size() Step 1: Using the Superstore Sales data, create a horizontal bar chart showing the Sum of Sales per sub category. To create this view drag sales in columns shelf and sub category in Row shelf.
  23. 23. Ranga Naik Step 2: Sort the sub category data to descending order Click sub category from column shelf -> select sort -> choose sort order i.e. Descending -> Choose Sort By (On which filed you want to short) -> choose aggregation Step 3: Create calculated filed i.e Top N and Bottom N_Rank_dense and use parameter what you created in method 1 In Calculation Mention any one of the formula i.e. a or b a) RANK_DENSE(sum([Sales])) <= [Top N and Bottom N parameter ] OR RANK_DENSE(sum([Sales])) > SIZE() - [Top N and Bottom N parameter ]
  24. 24. Ranga Naik b) RANK_DENSE(sum([Sales])) <= [Top N and Bottom N parameter ] OR [Top N and Bottom N parameter ] > SIZE() - RANK_DENSE(sum([Sales])) Step 4: Drag calculated field into filter shelf and choose “TRUE” Step 5: Enable the parameter and Label you will get desired result in a Single view.
  25. 25. Ranga Naik Notes :  If data contains duplicate measure values than go for Method 1 i.e. Using Set , Method 6 i.e Rank_Unique () , size() and Method 8 i.e Rank_dense (), size()  Please refer below url for tableau workbook. https://public.tableau.com/profile/publish/topnbottomnanalysis/rank_denseandsiz emethod8#!/publish-confirm
  26. 26. Ranga Naik
  • HarishKVReddy

    Jun. 7, 2021
  • SanthoshShavukaru2

    Apr. 15, 2020
  • BrookeSummers2

    May. 15, 2018
  • srikanth7bi

    Apr. 28, 2018
  • ShailendraOjha1

    Nov. 30, 2017

Top N and bottom N view on the same worksheet In Tableau with 8 methods

Aufrufe

Aufrufe insgesamt

2.503

Auf Slideshare

0

Aus Einbettungen

0

Anzahl der Einbettungen

2

Befehle

Downloads

1

Geteilt

0

Kommentare

0

Likes

5

×