Search code examples
sortingpowerbipowerbi-embeddedcolumnsortingpowerbi-datasource

How to have multiple column sorts in Power BI desktop/online with directquery


I have matrix visualization with multiple columns say:

ProjID ProjName Budget Proj_Status project_duration

I want to do a multiple column sort (like in Excel) first on Budget then on Project_duration in Power BI.


Solution

  • From the Query Editor, sort by one column then edit the formula to include the second column like this...

    = Table.Sort(#"Reordered Columns1",{{"OrdersCount", Order.Descending},{"OrderDate", Order.Descending}})
    

    You must comma-delimit each column header and ordering option within curly braces.

    Example:

    {{"1st_Sorted_Column_Header",Order.Ascending},{"2nd_Sorted_Column_Header",Order.Descending},{"3rd_Sorted_Column_Header",Order.Descending}}