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.
alexa_0028 Would need to understand this better. PBI sorts text fields alphabetically and numeric fields numerically. You can set a custom Sort By column if you want something different.
Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.