This is because a table calculation is being applied, and depending on how the view is sorted could give different results. The following forum post may provide some insight:
what you explicitly asked for is to sort a table calc based on the result of another table calc, and Tableau cannot do that specifically.
What you do have for an option is to change your approach, and instead of using table calcs, use aggregations on IF/IIF statements to enable sorting on the value that you want.
If you can upload a sample packaged workbook (.twbx) that represents your situation, an example solution can be created for you.
Hi Joe, thank you for the reply. Here is a sample I create to represent my situation. In this sample if I want to make top 2 list, it will show C and D as opposed to A and D for table calcuation value. Thanks.
Sample.twbx.zip 10.2 KB
Hi, this is great, but I need to do it for each category (which I have already created a calculated dimensions field for) do I need to
add the original dimension or the calculated field to this calculated field? If so, how would this be written?