4 Replies Latest reply on Nov 15, 2018 10:47 AM by Larsen Rennie

# Sorting Issue with Multiple Measure

Hello All

I am facing one issue in which i have created bar chart in tableau which is displaying multiple measure. One displaying Sum(Sales) and other Displaying Avg(Profit). Now the problem is that i am able to sort by Sum (Sales) by descending order which is highest to lowest using Rank function but for Avg(Profit) is not displaying in descending order . Please find below the image and attached is the twbx file . i am using superstore data set • ###### 1. Re: Sorting Issue with Multiple Measure

(V 9.3 here)

When you say you can sort by sum of sales, ... sort what?  Sub categories within the category dimension?

Where is your sorting being done in this sample workbook?

• ###### 2. Re: Sorting Issue with Multiple Measure

Hi Joe

i have not included the rank function over here in attached workbook but that's how i used to do sorting earlier using rank function . For example i will write the formula as Rank(sum(sales) and then drag the calculation in between the Category and Subcategory dimension and it will sort .But by looking at the scenario  which i have posted i think my question is invalid i guess because i think we cannot sort subcategory in descending order for two measure

• ###### 3. Re: Sorting Issue with Multiple Measure

Create a parameter to choose between Sales and Discount.

Then create a calc called [Measure to sort].  It will look like this:

if [Parameter 1] = "Sales" then [Sales] else [Discount] END

Then create a calc called [Rank calc].  It will look like this:

Rank(sum([Measure to sort]), 'desc')

Use that calc for sorting.  When you change the parameter, you will rank by the chosen measure.

PS:  I notice you want to do AVG on one measure and SUM on the other.  So you'll make the Rank Calc like this:

IF [Parameter] = "Sales" then

Rank(sum([Measure to sort]), 'desc')

Else

Rank(AVG([Measure to sort]), 'desc')

END

• ###### 4. Re: Sorting Issue with Multiple Measure

Thanks Joe i think it will work for me