2 Replies Latest reply on Jun 26, 2018 9:34 AM by Denis Poat

    TOP VS INDEX() filtering.

    Denis Poat



      I have a datasource with about 10M rows of data and have to give user the possibility to

      view some detailed data. The questions is what is the fastest to use: filter with option TOP N

      or INDEX() function? Is top N just a simple select top(N) ... from table or something more?

      Is index() verified for each of the rows or just for the TRUE value (I use a parameters to show to the user

      at most 10K rows of data, I know it's not cool to load so much data in a dashboard but this is the requirement)?

      I use the logic if INDEX() is less than parameters return TRUE else FALSE.


      Maybe there is a better solution?



        • 1. Re: TOP VS INDEX() filtering.
          Santiago Sanchez

          Hi Denis,


          In this situation I'd use a TOP. INDEX() is a table calculation, that meas it runs on top of the data loaded in a sheet. In your case, if you have many many rows returned by the database, those would all have to be transported to Tableau, loaded into a view, and only then filtered (more like hidden) to the end user. TOP on the other hand pushes the filter down to the database, it effectively will cause only the TOP N rows to be sent back to Tableau and rendered (it is, as you just, a simple SELECT TOP N).


          This article might be helpful to understand where each operation happens: Tableau's Order of Operations


          If you are ever curious about how long each operation is taking and where are potential bottle necks, the performance recorder is a good place to start: Record and Analyze Workbook Performance


          Hope this helps!


          2 of 2 people found this helpful
          • 2. Re: TOP VS INDEX() filtering.
            Denis Poat

            Yep, it helped. Also, I have some filter options, using that article added them to the context and it wasn't an issue.