As you've seen from your research there are several ways of doing this...attached is one method using index() to filter the Top N.
This is the same 'theory' as the LOOKUP solution, but a bit simpler to follow. The reason it works, is due to Tableau's 'Order of Filter Operations'
Index() is a Table Calculation, and as we're using this to filter (and Table Calc Filters are applied last) this has the affect of Filtering the View, but not the underlying data, so any %age of Total are still correct.
in the attached I've brought index() into the view so you can see what it's doing, but any final solution will only need the filter part. So the key here to sort the bars by the measure (in this example sales). This way by running the index() function 'Table Down' it acts like a Ranking function (you can set this up in the Table Calc itself, but it's easier to sort the view). I've then created a Boolean filter (based on a parameter I've created, so the user can choose their N)
'Show Top N Filter'
index() <= [Show Top N]
I hope this makes sense, and solves your issue, but please post back if not (there are a few other ways to go, if this one doesn't do the job)
Show Top N - index calc.twbx 331.5 KB
Thank you for responding. I do not see any attachment. Could you please
How do I create a table calculation? As you can see, I am still a beginner.
On Wed, Oct 28, 2015 at 3:00 AM, Simon Runc <
Can you not see this?...Let me know, if not, and I'll try and re-attach it. But you should be able to just click on the attachment and it should download
Table Calculations are just a particular type of calculation. So by using the function index() it is a Table Calculation. Tableau does have 'Quick Table Calculation', but all this is doing is building you a formula (for the most common use-cases - such as Percentage Difference, Percent of total...etc.) using the various Table Calculation functions.
I'd advise starting with the on-demand videos. In the Calculations section there are some on Table Calculations to get you familiar with them and the concept. After that I'd then watch Jonathan Drummey's excellent TDT video
Hope that helps, but please post back if you can't get the attachment.
Simon, Thank you so much. I am able to see the attachment. With your help,
I am able to get it to work.
On Wed, Oct 28, 2015 at 10:36 AM, Simon Runc <