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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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