13 Replies Latest reply on Dec 21, 2016 8:24 AM by Simon Runc

    Persistent Sorting with 'Measure Values'


      Hi all,


      Is there any way to get a sort to persist when using 'measure values' on a bar chart (on the row axis) or do I have to use each individual measure for that to be a possibility? I am trying to get a chart to sort in ascending order for whatever selection I make from the filter (single value drop-down). Currently the sort resets every time I make a new selection.


      Unfortunately I'm unable to attach a workbook as it is proprietary information. Thanks for your help!

        • 1. Re: Persistent Sorting with 'Measure Values'
          Simon Runc

          hi Rohan,


          I think the easiest (and maybe the only) way to do this, is to use a parameter as a measure selector, rather than use the Measure Names/Measure Values. As you are only selecting one measure at a time, a parameter will be fine for this.


          Here's a link to how to do it...Breaking BI: Dynamically Choose the Fields Displayed on a Chart in Tableau


          you can then also use the "Selected Measure" field for your sort.


          hope that helps

          • 2. Re: Persistent Sorting with 'Measure Values'

            Hi Simon,


            Thanks for the reply. To provide a little more context, the graph shows responses to a series of questions (approx 70) and the filter is on a list of organizations, where I can select which org I want to view the responses for. If I'm understanding correctly, the org names would be used as the allowable values in the parameter? There are approximately 2300 orgs so I just want to be sure before I do anything.


            Thanks again,


            • 3. Re: Persistent Sorting with 'Measure Values'
              Simon Runc

              hi Rohan,


              So just to ensure I fully understand...


              The selection is not made on Measure Names, but on the Organisation Name? and when you select an organisation you what do you want sorted, and how do you want it sorted?


              if you are just filtering on Organisation, where the measure (and thus sort) is based on the same field...regular filtering should work


              Sorting on Selection.gif


              Can you let me know if (and if so how) your situation differs from the above gif?

              • 4. Re: Persistent Sorting with 'Measure Values'

                Hi Simon,


                I think your example is similar but not quite what I have. I have 'measure names' and 'organization name' set for columns and 'measure values' (all of the questions) set for rows. The single selection filter is on 'organization name' and whenever I change the selection the sort of the chart is reset. I'm trying to get it to stay in the order I select (highest values to lowest values).


                Hope that helps.




                • 5. Re: Persistent Sorting with 'Measure Values'
                  Simon Runc

                  hi Rohan,


                  Right I think I have it...Can I just check. So you do have multiple measures? You manually select one of these measures to sort-by (using the manual sorters at the bottom of each measure axis), but when you change the [organisation name] the sort is lost?


                  If so are you unable to just use that field (the one you added the manual sort) into the automatic sort (the one controlled from the dimension)


                  I've attached an example of what I think you are describing (where you can change the filter on Category, and the sort remains on Sales, even though both Quantity and Sales are in the Viz). If this isn't how your situation is, can you amend the attached (or create your own example), to reflect your situation.

                  • 6. Re: Persistent Sorting with 'Measure Values'

                    Hi Simon,


                    I have two dimensions, 'org name' and 'measure names' on the columns shelf, and 'measure values' on the rows shelf. I did notice that when I click either 'sort measure names by measure values' button the graph does sort but when I change the org it defaults to the order that the 'measure values' are sorted in. I have attached a few screenshots, showing the current order of 'measure values', what the graph looks like after clicking one of the sort buttons in the top toolbar, and what it looks like after I change an org.


                    Thanks for all of your help.



                    • 7. Re: Persistent Sorting with 'Measure Values'
                      Simon Runc

                      So if you set up the sort (on the measure you want) from within the sort option, rather than use the "single click" sort, this should retain the sort on that measure




                      In my example, although I have both Sales and Quantity (as measure names/values) in the Viz, by setting it up this way the chart is always sorted on Sales, even when I change another filter.


                      Sorting on Selection.gif


                      Does that do the trick?

                      • 8. Re: Persistent Sorting with 'Measure Values'

                        Is there any way to set up this sort on 'measure names'? When I try doing it on org the graph does not update and on 'measure values' it is not an option at all.

                        • 9. Re: Persistent Sorting with 'Measure Values'
                          Simon Runc

                          Not sure I understand...going back to my example 'Sales' is a measure name, so of the 2 measure names that is the one I've selected to sort the states by. If there were an option on 'measure values', which measure value would Tableau choose?


                          Unless you mean that you want the measure names sorted...so in your screen shots is it that you want the measure names to resort so it would go Q1, Q2, Q3....Q60. If that's the case then you can sort the measures alphabetically, by applying the sort to Measure Names



                          In your case, due to their names (Q1, Q2...) they would get sorted in the correct order.

                          • 10. Re: Persistent Sorting with 'Measure Values'

                            I apologize! I meant measure values, this is what my column/row shelves look like. I have removed superfluous measure values from the card so only have what i need shown. Guessing there is still no way to sort on it?






                            • 11. Re: Persistent Sorting with 'Measure Values'
                              Simon Runc

                              OK I think I see now...hopefully, you see why creating an example workbook is useful!! (it doesn't take long...this is the 2nd one [attached] that I've created...taking about 2 mins)


                              So you should be able to sort on Measure Names to keep them in the right order (you may need to rename measure names for Q1, Q2...Q9 to Q01, Q02...Q09, so that they are in Alphabetical Order)


                              In the attached, I've created (what I think!) is your scenario.


                              I this I've sorted the measure names as follows




                              Now I've actually sorted mine in Descending order...Tableau actually put them in the right order, so wouldn't have demonstrated my point very well!! (btw when I do this I don't drag the fields into the measures pane...I bring measure names onto filter -> filter to the ones I want -> then bring in measure values and measure names to the row and column shelves)

                              1 of 1 people found this helpful
                              • 12. Re: Persistent Sorting with 'Measure Values'

                                Perfect, thank you very much for your patience and help! I inherited this workbook and am new-ish to Tableau so was a little unsure on how to replicate this problem but you were able to identify it. Really appreciate it!

                                • 13. Re: Persistent Sorting with 'Measure Values'
                                  Simon Runc



                                  no problem...glad we managed to solve it in the end (that's the important thing) and yes I know all about inheriting workbooks!!


                                  Measure Names and Values can be a little odd, as they are not proper dimensions/measures, so lack some of the control you get with regular dimensions/.measures