Yes you can! How? With a parameter.
Let’s use the Superstore datasource for this example. Our use case will be to create a view showing Profit Ratio, Sales and Profit per Order and allowing the user to choose which of these they want the Orders to be sorted by.
How to do it
1 – Create a parameter
Your first step is to create a parameter with the fields the user can sort by – in this case, Sales and Profit.
2 – Show the Parameter Control so that you can test it
3 – Create a Calculated Field to use that Parameter
The next step is to create a Calculated Field that will reflect what the user chooses in the Parameter Control.
In this case, this is the code for it:
IF [Sort by] = “Sales”
ELSEIF [Sort by] = “Profit”
4 – Sort by that Calculated Field
The last step is to just click on the field you want the user to choose how to sort and click on Sort…
You want to configure it so that it is sorted by Field and then select the calculation you just created on Field Name.
And it’s done!
If the fields you want the user to sort by require different orders (i.e. some Ascending and others Descending) you can add a minus in the Calculation you created in order to manipulate that order! That will not affect the value in the view, it will only change your sorting!