Anyone have idea how to resolve sorting issue by calculated measure?
It's not possible to sort by a table calculation--they're highly dependent on the view. One way to get the view to sort as desired, would be to hover over the Select Measure axis and click the desired sort button. However, when a different measure is selected, this will need to be done again.
Hope this helps a bit!
There is workaround that allows automatic sorting by a table calculation.
- Add a second copy of the table calc pill to the view. In your example I added a copy of Selected Measure to the Columns shelf.
- Convert this pill to discrete.
- Move the pill just to the left of the dimension you want to sort. In your case left of Country, right of Week.
- Unselect Show Headers on the Selected Measure pill.
The default Tableau sort behavior is to sort by the discrete pills: Week then Selected Measure then Country. Note that you can't change the sort order of a table calc field, but if you want the countries sorted from largest to smallest, just create a new calculated field Selected Measure Sort = -1 * Selected Measure.
Since each discrete pill creates panes and borders around the panes, you'll want to select from the top menu Format > Borders > Columns and move the Column Divider > Level one notch to the left.
Excellent solution. It is resolved my issue. Thanks once again.