From the Custom List designer, click the Script Mode button to the build custom lists in the integrated development environment (IDE). To build your custom list, add the required functions, hierarchies, and elements, or simply type your formula. The script language is PQL, unless working with an MS OLAP or Tabular model, in which case the script language is MDX.
Follow the example below to learn how to build a custom set that sorts its members in ascending order:
Open the Set functions, and drag the Order script onto the script window.
Remove <set definition> and replace it with the All Members function under Member.
Remove <model attribute uniqueName> and replace it with the required hierarchy from the Hierarchies panel.
Remove <numeric expression> and replace it with the required measure from the Measures panel.
Replace <type> with asc, and remove the square brackets  around it.
Test the script and save it to the CMS.