3 Replies Latest reply on Jun 8, 2018 9:39 AM by christopher.richards

# Problem with sorting

Hi, All,

I'm having trouble implementing a dynamic sort.  In the past I've been able to create a parameter with a list of the names of the measures that I want to sort by and a calculated field that is essentially a case statement that says if parameter = "x" then sum(x)....  I can then sort by this calculated field and the parameter allows the sorting to be dynamic.  For whatever reason though the calculated field is not displaying in the sort by drop down menu.  I've attached a copy of the superstore data as an example.  Any ideas?  Thanks!

• ###### 1. Re: Problem with sorting

I can't open your workbook but think I know the answer. Drag your sort pill to the rows shelf, set it to discrete (blue) and place it as the left most pill, in front of the sales person pill. You can un-check Show Header to hide it. You might need to multiply by -1 to get the correct sort order.

• ###### 2. Re: Problem with sorting

I believe it's because you are using ATTR in your Sort Field calculation.  Per the Tableau help page, ATTR cannot be used in a sorting function on a cross tab.

This is because you can get '*' as a result with ATTR and it doesn't know how to make the sort.  Your formulas are resulting in '*' values in some cases.

Try changing your formula to use another aggregation that is appropriate (MIN, AVG, etc).  I used MIN in my example below, but you'll want to test to make sure you're getting the values that you want from each selection.

I was able to choose the Sort Field as an option with this change.

Alternatively, you could pre-aggregate your calcs for commission and achievement, in which case you would not need to specify aggregations for them in your Sort calculation.

Example with commission:

Either of these should work, just depends on your use case and making sure it calculates as expected.

- Jim

1 of 1 people found this helpful
• ###### 3. Re: Problem with sorting

This fixed it.  Thanks, Jim!