Sorry, I realized I right-clicked on the dimension in the wrong place (on the left panel rather than the top one).
This made me realize the reason why the sort still doesn't work in the original file.
What happens is that if a "query" is the exactly the same for two or more countries, Tableau sums up the total number of clicks for that query regardless the country, hence some queries are not correctly sorted.
So, my question now is: how can I make the sort working the way I want which is "when I select a country I want the table always sorted by number of clicks for the country selected in my filter" when 2 or more value under the dimension "query" are exactly the same?
Thank you for your help!!!
Not sure why this happens, but if you right click the [Queries] pill in the Dimensions pane and set the default sort option it will not show you the option to sort by field values. If you right click the [Queries] pill on the rows shelf then you will have the option to sort by field values as Tushar showed.
thank you for your feedback. I think I have solved that whilst you were writing
Unfortunately this didn't made the table sorted like I wanted, please see above.
This has been solved by:
1) Right clicking on the dimension in the row shelf
2) Creating a combined dimension (in my case Country&Query) so that the query is "unique"
3) Adding the new Dimension to the row shelf and unticking "Show Header"
Now, when I change the country, the table is always sorted the way I want.