- ·In a text table, Sorting is first and foremost controlled by the dimensions in the header pane. Records are first sorted to the highest most dimension (ie. farthest to the left on rows shelf) and so on for the second highest etc.
- ·Data pane field sorting can only be done within the above context to dimensions in the header pane which means to the lowest level dimension in the header pane (dimension farthest to the right in rows shelf).
- ·If you only have one dimension in your header pane then sorting can be purely done on any of the data pane fields independently. One way to get only one dimension in your header field but also having information from multiple dimensions is to combine all needed dimensions into a single “flat” dimension.
Please follow the below approach
You can easily sort your data by different dimensions when you use a parameter control. For example, you have several dimensions—Item, Category, Department, and Region—and you want to be able to select the dimension from a drop-down list by which to sort the data. To do this, complete the following tasks:
Create a parameter with the dimension values you want to sort by and show the parameter control in the view. Create a calculated field used to perform the sort. Build the view.
Thanks for your response Rajeev!
So I created parameter and then calculated field but my formula is an error because I have date and $$ and String in dimensions. Would I have to change the way I set parameter? If I choose data type as Float - I'm not able to list dimensions. Still learning tableau language....
what am I doing wrong?
The Problem is related to the Data type mismatch.
Just try to understand.. when I defined the parameter, i have taken the data type as "String" and as per case statement what I am saying when 'Department' THEN [Department]. If you follow closely the data type , you will realize department is also a String type . I mean to say prefix "abc" is present in the starting of the Department. Similarly for other dimension.
CASE [Sort By]
WHEN 'Department' THEN [Department]
WHEN 'Category' THEN [Category]
WHEN 'Item' THEN [Item]
WHEN 'Region' THEN [Region]
But as per your screenshot ,I think you are using some measures that's y u r getting this error.it would be great if you can attach the sample workbook.Please let me know if you need any further assistance.
if you want you can also change the granularity of date by creating a calculated Field and used this new calculated field with the Case statement
In the Data Window, right-click the Order Date field, and then select Create Custom Date.
In the Create Custom Date dialog box, do the following:
Give the custom date a name. For this example, enter Order Date - Year.
For Detail, select Years. Leave the Date Value selected.
Purvi Ajmera if i understood your requirement from the UI stand point of view ..your users should see the sort icon when they hover on the measure field? am i right?
Parameters approach works fine, but from user stand point of view make use of measure names and measure values and achieve the sort on the measures...it will work fine.
Let us know for any help...
I realize that yes I do have mismatch data type but how can I overcome it? I tried to create different parameter for each and then doing a calculated field but it did not work. Attached is my sample workbook if it helps to understand where I’m stuck- any help would be much appreciated !!
Sample Dashboard.twbx 1.0 MB
I tried to open your workbook but i couldn't it took 21 minutes..and still showing executing query.