Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
AakashMarasini
Frequent Visitor

Custom Sort in custom Visual Urgent

Hello Developers!

I am having many categorical data so I have to use the custom sort in my custom visual.

I have followed the documentation : https://learn.microsoft.com/en-us/power-bi/developer/visuals/sort-options

But the sorting options (menu) is not generated in the power bi so that i can change the order of each data fields as per my wish.

I have implemented as follows:
Visual.ts: 

 

 

 

 

 

import CustomVisualApplyCustomSortArgs = powerbi.extensibility.visual.CustomVisualApplyCustomSortArgs;

//In VisualUpdateOptions:

let queryName1 = datas.categorical.categories[0].source.queryName;
  console.log('queryname1',queryName1)
//output: Table.columnName
  let queryName2 = datas.categorical.categories[1].source.queryName;
  let args: CustomVisualApplyCustomSortArgs = {
      sortDescriptors: [
          {
              queryName: queryName1,
              sortDirection: powerbi.SortDirection.Ascending
          },
          {
              queryName: queryName2,
              sortDirection: powerbi.SortDirection.Ascending
          },
      ]
  };

this.host.applyCustomSort(args);

 

 

 

 
capabilities.json:
 

 

 

"sorting": {

  "custom": {}

}

 

 

I have also looked into the other custom visual open source. All of them are using implicit and default method.

Thank You!

@v-viig @dm-p 

2 REPLIES 2
dm-p
Super User
Super User

Hi @AakashMarasini,

 

I don't have any experience with the custom sorting API, but my understanding is that it will not add anything to the visual header, which is what default sorting is for. This custom API is intended for more complex scenarios than the visual header UX can manage, and I believe that it's something that the developer has to manage the display of (and add elements to manage the sorting operations for and drive this API) in their visual DOM.

 

Regards,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Hi @dm-p 
Thank you for your response. I thought I should use the custom API to have sort options for multiple data fields. If I cannot add a sort option to the visual header using the custom API, how could i achieve this feature?
With the default sort, sort options are not available for all my data roles. It is available for only two data fields: one categorical and one measure respectively in my case. 

I have used as:

"sorting": {

  "default": {
   
  }

}


Regards,
Aakash

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

Top Solution Authors