{"id":346,"date":"2014-07-29T17:43:59","date_gmt":"2014-07-29T17:43:59","guid":{"rendered":"http:\/\/arunethan.com\/?p=346"},"modified":"2015-12-01T16:30:56","modified_gmt":"2015-12-01T16:30:56","slug":"sorting-in-tableau","status":"publish","type":"post","link":"http:\/\/arunethan.com\/?p=346","title":{"rendered":"Sorting in Tableau"},"content":{"rendered":"<div class=\"pf-content\"><h2><span style=\"color: #000080;\">Basic sort<\/span><\/h2>\n<p>Right click on the discrete<sup>1<\/sup> field in the rows or columns shelf<\/p>\n<pre><sup>1<\/sup> Sort can be performed only on discrete fields or measures which is converted to discrete<\/pre>\n<p><a href=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-347\" src=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort1.png\" alt=\"sort1\" width=\"502\" height=\"544\" srcset=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort1.png 502w, http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort1-276x300.png 276w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<p>The discrete field can be sorting by<\/p>\n<ol>\n<li>Data source (if the field is pulled from a SQL data, this order is based on sort orders applied to this relation)<\/li>\n<li>Alphabetically<\/li>\n<li>Based on another Field across different aggregation level<\/li>\n<\/ol>\n<p><a href=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-352\" src=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort11.png\" alt=\"sort1\" width=\"493\" height=\"491\" srcset=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort11.png 493w, http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort11-150x150.png 150w, http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort11-300x298.png 300w, http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort11-160x160.png 160w\" sizes=\"(max-width: 493px) 100vw, 493px\" \/><\/a><\/p>\n<h2><span style=\"color: #000080;\">Non-Nested Sort<\/span><\/h2>\n<p>The nature of the sort function in Tableau is that sorting is done at the content level.<\/p>\n<p>When a sort is done based on the SUM(profits) descending, you can notice that CENTRAL market is at the top. This because the aggregate SUM of CENTRAL is the maximum. Similarly COFFEE product type as a MAX of SUM(PROFIT) arranged descending. Hence it is at the top across all the Markets. The results are not sorted based on the Markets but to the entire context.<\/p>\n<p>This is the default behavior within Tableau.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-353\" src=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort2.png\" alt=\"sort2\" width=\"770\" height=\"360\" srcset=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort2.png 770w, http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort2-300x140.png 300w\" sizes=\"(max-width: 770px) 100vw, 770px\" \/><\/a><\/p>\n<h2><span style=\"color: #000080;\">Nested Sort<\/span><\/h2>\n<p>If the results is expected to be sorted based on the markets,\u00a0 we have to create a nested sort using a work around.<\/p>\n<p>In the dimensions pane, press the CTRL key, and then select the dimensions. Right-click on e of the selected fields and click on Combine Fields option. The newly combined field, Market &amp; Product Type is created. Drag this field to the Rows panel and set the sort options. We will get a nested sort output.<\/p>\n<p><a href=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-354\" src=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort3.png\" alt=\"sort3\" width=\"802\" height=\"360\" srcset=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort3.png 802w, http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort3-300x134.png 300w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<h2><span style=\"color: #333399;\">Selected Sort<\/span><\/h2>\n<p>With the previous sort you can add more measures but the results will still be still sorted by PROFIT<\/p>\n<p><a href=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-355\" src=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort4.png\" alt=\"sort4\" width=\"426\" height=\"437\" srcset=\"http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort4.png 426w, http:\/\/arunethan.com\/wp-content\/uploads\/2014\/07\/sort4-292x300.png 292w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><\/h2>\n<p>&nbsp;<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Basic sort Right click on the discrete1 field in the rows or columns shelf 1 Sort can be performed only on discrete fields or measures which is converted to discrete The discrete field can&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":354,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[55,57,56,54,28],"_links":{"self":[{"href":"http:\/\/arunethan.com\/index.php?rest_route=\/wp\/v2\/posts\/346"}],"collection":[{"href":"http:\/\/arunethan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/arunethan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/arunethan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/arunethan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346"}],"version-history":[{"count":6,"href":"http:\/\/arunethan.com\/index.php?rest_route=\/wp\/v2\/posts\/346\/revisions"}],"predecessor-version":[{"id":358,"href":"http:\/\/arunethan.com\/index.php?rest_route=\/wp\/v2\/posts\/346\/revisions\/358"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/arunethan.com\/index.php?rest_route=\/wp\/v2\/media\/354"}],"wp:attachment":[{"href":"http:\/\/arunethan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/arunethan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/arunethan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}