Disable Highlight

Thursday, May 1, 2014

How to display Top N Rows , when connected to cubes





My data source is cubes, I am able to get the top 20 rows and display them, But when i am trying to fill the color field tableau is again ranking the data based on color.

Here is the Pic showing with out adding color



After dragging color to the view, the data now doesnt display the top 20 correctly it displays more than 20 rows, data get ranked again based on color.




Steps to follow to display top N rows


  • Create a calculated field called Index with the code Index()
  • Place it on Rows, right click it and make it discrete. Then move it to the left of the dimension that's on Rows (since I don't know the name that dimension, I'll call the field RowDim)
  • Right click Index and select "Edit Table Calculation". What you want is to get it so that the Index is calculated at the level of RowDim without Status playing a role in partitioning. So, select "Advanced" from the Compute Using drop down and move both RowDim and Status from Partitioning to Addressing with RowDim on top.
  • Click OK and then on the first screen select RowDim from the "At the Level of" drop down and then click OK.
  • Hopefully what you see is each row getting a proper sequential index. Assuming your view is sorted, the index should match the RowDim with the highest purchase price being 1 and then counting up.
  • Right click the Index field and make it continuous (this is not entirely necessary, but will make the next step easier). You'll notice that it now moves to the right of RowDim. This is because Tableau always keeps discrete fields on Rows and Columns (which create headers) to the left of continuous fields (which create axes).
  • Drag the Index field from Rows to Filters. 





1 comment: