Search code examples
tableau-apioutlierscalculated-field

Sort Tableau bar char by year percentage difference top 5


I have a bar chart sorted by year over year percentage difference and I have excluded values that are too large (over 400% year over year difference) . I want to show the top 5 for each category using a parameter variable("TopN"). The bar chart shows less than the allocated parameter amount (5) for some of the categories selected even though there are values there. I used the following code below.

if [index]<=[TopN] THEN "Top N" ELSE IF [index]>=SIZE()-[TopN] THEN "Bottom N" ELSE "Middle" end

END

When I remove the filter to remove the too large values I mentioned above I am able to see the correct number but I don’t want those values to be shown and want to see the top without the large values(outliers).


Solution

  • I used sets to exclude the values that were too large. And that worked for me. It removed the large values and when I applied the top N filter. It now it gives me what I was looking for.