Forum Discussion
What is the sorting algorithm used by PBI?
- Anonymous4 years ago
Hi alexa_0028 ,
As far as I know, Power BI will sort your data based on data format. As normal, Power BI will sort the numbers according to their size or dates according to chronological order.
If you have multiple different data in one cell like number, text, and delimiters. For example: 1,10,ACE
The data type of this columns is text. Power BI will sort this column by each value in same position in cells.
For example there is a column with two rows.
row1: 1,10,ACE
row2: ACE,10
This column is in text format. Power BI will sort row1 and row2 by first value in them. 1<A so Power BI will use this sort to sort the column. If the first data in row1 and row2 are both 1. Power BI will compare the second value in them until get the result.
From my test, I know sort is delimiters<number<text. And delimiters/numbers/text still contain the normal logic in them. Like 1<2<3... A<B<C...
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Thanks for the information. But in the case my filed is not fully alphabetically or numerical. However, when I sort this column in PBI the sorting doesn't match with the sorting in the database(source of data) as database sorts with ascii key.
Can someone please explain the rule in case of mixed column for PBI sorting? Is there anyway to do the sorting as ascii in PBI as well?
alexa_0028 Sorting and string comparison - Globalization | Microsoft Docs
I would call Power BI's mixed alphabetical sorting to be the generally "normal" way of sorting based upon special characters first, numbers and then letters. Now in this sorting you will get things like , 1, 10, 11, 2, 20, 3, etc.
If you want a different sorting order, you could create a new column and use the UNICODE function, for example. Sample data would help to be more specific.