Close this search box.

Power BI Custom Visual Sorting

The Power BI Custom Visual framework provides a lot of flexibility when it comes to sorting your visual. By default, the visual is sorted based on the sort order of the data in the table. However, it is quite easy to specify your own sort logic.

Following are the 3 different options which can be used to sort your visual. They are as follows:

  1. Default Sorting:
    This is the easiest sorting option and gives users the ability to sort the visual by any field used in the visual. The following code needs to be added to the capabilities.json file. 
     "sorting": { "default": { } }
    After this the user will get the below sorting option:
  2. Implicit Sorting:
    Implicit Sorting can be used for pre-defining your sorting order in your capabilities.json file. Here, the user cannot manually change the sorting order. This can be done with the following code block where direction 1 is ascending and 2 is descending. Role is the data mapping name for which you would like to define your sorting.
     "sorting": {
            "implicit": {
                "clauses": [
                        "role": "category",
                        "direction": 1
  3. Custom Sorting:
    Custom sorting can be used for defining sorting in your visual.ts file and not in the capabilities.json file. Since you are defining your sorting order in your code, you can use various different logics to define your sorting(For example, you can define a formatting toggle option in the format pane that will sort the visual when turned on). A simple codeblock that can be used for sorting your datapoints in ascending order is as follows.
     sort((category1, category2) => category1.value - category2.value);

In sum, there are quite a few options available to sort your visual as and when needed!

Scroll to Top

Get In Touch

Set up a free Consultation today!