2 Replies Latest reply on Feb 1, 2019 12:53 PM by Paweł Łebek

# How to filter Top N using Grand Total

Hi All,

I am currently struggling with building filter (Parameter?) that would work for discrete Dimensions for Grand Total ALL

I have two dimensions in two columns: Country and Products per country. Then I have SUM of items [Number of Records] in columns per Order_Date (Year/Month).

Country
Product
October 2018
November 2018
December 2018
Grand Total 2018
January 2019
Grand Total 2019Grand Total ALL
PolandProduct 110101030151545
Product 2555156621
USAProduct 1100100100300150150450
Product 25050501506060210
Product 3...............

I am trying to create Filter or Parameter that would allow me to filter Top N Products for every Country separatelly having as a calculation the biggest sale but using Grand Total for every Country.

I tried Filters, Parameters, INDEX(), Sets.. The challenge is that if I would like to use filter on Order_Entry date - the Grand Total ALL changes for particular Products thus an order of Top N may change.. I cannot achevie it so Top N works. Is there any solution to this?

I am using Tableau 10.2.1

Pawel

• ###### 1. Re: How to filter Top N using Grand Total

Pawet,

Find the attached workbook.

I used Superstore example

Create a calculation that calculates the Sales for all the months for the respective Region and sub-category using

{Fixed Region, Sub-Category: SUM(Sales)}

Make your date range selector filter context because 'Fixed' operates before dimension filters and after context filters

Tableau's Order of Operations - Tableau

This gives you Grand Total for all the months and place this one on the rows and sort descending. The create a index calculation and have it computed Table down restarting every region. This should act as Top N filter as the grid is sorted in descending order based on the Grand total calculation. Let me know if you're stuck somewhere.

1 of 1 people found this helpful
• ###### 2. Re: How to filter Top N using Grand Total

Hi Maneesh,

This is great! It works perfectly.

Thank you very much for help.., and for the link to Tableau`s Order of Operations

Thanks again,

Pawel