How To Use A Parameter To Create A Custom Sort Based On Multiple Measures (Part 1)

by Maleeha Ahmed

If you would like to create a view with multiple measures, you may want to allow your audience to choose which measure they would like to sort the view in and in which direction they would like to view it i.e. ascending or descending.

Example:

 

First Step: Create Your Parameters

In your data pane click on the little arrow and a box of options will appear. Here you can select “Create Parameter”

Once you have selected this option a new configuration window will appear.

 

– Input a useful title for your parameter

– Pick your data type. For this use case, I will be using ‘String’ as I am using words

– Allowable Values – for this I am using a list

– Add the measure names you would like to allow your audience to sort their view by.

 

Second Step: Create the calculation to connect your parameter to the data set.

Calculation explained:

This is telling the calculation that we want to configure the parameter “Select a Measure”

This is saying, when we wrote “Profit” in our parameter set up, we were referring to [Profit] – the measure in our data.

Again like before, “Sales” means [Sales] the measure in our data

You must end your CASE statements

 

Third Step: Repeat Step 1 and 2 for the “Sort” parameter

– Name your Parameter

– Data type: String

– Allowable Values: List

– Name your selections within your Parameter: Ascending/Descending

 

After creating the parameter, like before, we need to connect this parameter to our data with a calculated field.

Calculation explained:

This Calculation is about the Sort parameter

This is saying when “descending” is chosen then return my measure but in a negative form.

This is saying when “Ascending” is chosen then return me my measures.

Then, as before you must end your CASE calculations.

 

After this, make sure you right click each of your parameters and click on “Show Parameter Control.” This will allow you to see and use your parameters. These will appear on the right side of your view.

 

With your measures, dimensions and parameters in view there is just one more step to configuring your parameters.

Right click on your dimension in your rows shelf, and click the option “Sort.”

This little configuration box will pop up. Click on “Data source order” and pick “Field.”

Now choose the measure in which you would like to organise your dimensions in. Here we will pick our “Sort Calculation” we previously created.

Leave the “Sort Order” on Ascending.

Now you should be able to select which measure you would like to sort the order of your dimension in, and in which direction.

 

If you would like to create a new parameter which allows the viewer to chose how many records they would like to see. Please find part 2 of this blog.