5 Replies Latest reply on May 29, 2014 2:12 PM by Aaron Clancy

# Sorting with parameters

Hi,

Newbie question here - I'm trying to learn how to sort with parameters. I have a chart and want the user to be able to sort by either (1) the latest value or (2) the difference of the historical average. I've found a couple of articles online but still can't get this right. Can anyone tell me what I'm doing wrong?

Thanks!

• ###### 1. Re: Sorting with parameters

In your scenario, aren't they the same order?   FYI you can't sort table calcs with the native sort so you have to get tricky with it.

• ###### 2. Re: Sorting with parameters

Thanks! I had previously added the calculated field "SortCF" to the Columns shelf but had my 2 columns in the opposite order. So the order of the columns makes a difference with the sorting ability?

In this case the 2 measures are the same but this is just a tiny subset of the dataset I am wrangling with.

So there is no way to sort when using table calculations?

• ###### 3. Re: Sorting with parameters

Well......"yes"     there is a way to sort it.  You just have to do it by placing it on the rows or columns and hiding the header.  It's a trick.  You could add another parameter called "direction" with values of ascending or descending and use that to determine whether you multiply the values by -1 or not.   So essentially it does the same thing as a sort but it's just a different user experience.

And to answer your question, the sort is based on the dimensions from left to right on the columns shelf.  If you have "discrete" values of your calc on the far left this will force it in to the header and those values will automatically sort ascending.  The trick is to multiply those resulting discrete values by negative 1 if you want to see them descending.

And you already figured out to use the parameter to control which measure populates the SortCF calc.

If they weren't table calcs you could have just sorted the dimension you have on columns by that calculation.

• ###### 4. Re: Sorting with parameters

NOW I get it - thanks= you! My problem was using the "string" rather than the "integer" functionality...

• ###### 5. Re: Sorting with parameters

Excellent.   String comparison works too, it's just much easier/faster to perform the logic with integers and the chances of missing a character is reduced when you're just comparing 1=1  or 2=2