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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Breacher
New Member

Sorting Rows in Matrix

I'm fairly new to PowerBI and I'm currently messing with data.  In excel, you are able to sort PivotTable rows with ease.  In Power Bi, it's a bit more difficult and I've yet to figure it out.  Below is what I'm trying to customer sort.

 

scrre111.png

6 REPLIES 6
mussaenda
Super User
Super User

you can add another column to assign a number for each row and then arranged it using that column

Where would I add the column, in the Bi data window? Each row has about 15 lines of data, so would I assign a number to each row title?

Try this:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtA1NlCK1YlWMjQy0AYzjA11zSBCZoa6lhCWpaEuUB7MdA4NCnL1C1GKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Inv Aging" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Inv Aging", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Inv Aging] = "0-30"
then 1
else

if [Inv Aging] = "31-60"
then 2
else

if [Inv Aging] = "61-90"
then 3
else

if [Inv Aging] = "91-120"
then 4
else

if [Inv Aging] = "120+"
then 5
else

if [Inv Aging] = "CURRENT"
then 6
else

null)
in
    #"Added Custom"

 

2019_11_21_10_09_38_Untitled_Power_BI_Desktop.png

You can go to edit queries then add custom column

 

if [Inv Aging] = "0-30"
then 1
else

if [Inv Aging] = "31-60"
then 2
else

if [Inv Aging] = "61-90"
then 3
else

if [Inv Aging] = "91-120"
then 4
else

if [Inv Aging] = "120+"
then 5
else

if [Inv Aging] = "CURRENT"
then 6
else

null

 

 

then close and apply entries

then click the Inv Aging and choose modeling

then Sort by Column

then choose the column you just made

 

The thing is, Inv Aging is not a column listed in the query editor.  It is a column I added in BI data.

Okay, it is not indicated on your question that it is a calculated column.

Anyway, there is still a solution for that.

Provide a sample pbix file to help you easier.

 

Thanks

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors