cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AlexCassin Frequent Visitor
Frequent Visitor

Re-ordering the x-axis values

Ive seen someone say they can use the Sort By Column button in the Modelling tab but thats greyed out for me.Capture.PNG

 

This is what I have but I want the order to be "< 1 Week", "1 Week - 1 Month", "1 Month - 3 Months", "> 3 Months"

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Re-ordering the x-axis values

Hi @AlexCassin,

 

We can add a custom column in power query and make the date column be sorted by the custom column.

 

if [date] = "< 1 Week" then 1 else if [date] = "1 Week - 1 Month" then 2 else if [date]= "1 Month - 3 Months" then 3 else 4

And here is the M code in advanced eitor for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOVjBUCE9NzVbSUTI0VIrViVaC8BV0gRK++XklGUAZI2OoDFgAKGUMYRWD5CC6wIalIksYmyAkkG0xIccWUxMcthgaY7XF2BSrsJkFLsvNjAhajlMuFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"sales", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "date"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each if [date] = "< 1 Week" then 1 else if [date] = "1 Week - 1 Month" then 2 else if [date]= "1 Month - 3 Months" then 3 else 4)
in
    #"Added Custom"

Capture.PNG

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

8 REPLIES 8
Community Support
Community Support

Re: Re-ordering the x-axis values

Hi @AlexCassin,

 

We can add a custom column in power query and make the date column be sorted by the custom column.

 

if [date] = "< 1 Week" then 1 else if [date] = "1 Week - 1 Month" then 2 else if [date]= "1 Month - 3 Months" then 3 else 4

And here is the M code in advanced eitor for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOVjBUCE9NzVbSUTI0VIrViVaC8BV0gRK++XklGUAZI2OoDFgAKGUMYRWD5CC6wIalIksYmyAkkG0xIccWUxMcthgaY7XF2BSrsJkFLsvNjAhajlMuFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"sales", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "date"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each if [date] = "< 1 Week" then 1 else if [date] = "1 Week - 1 Month" then 2 else if [date]= "1 Month - 3 Months" then 3 else 4)
in
    #"Added Custom"

Capture.PNG

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

AlexCassin Frequent Visitor
Frequent Visitor

Re: Re-ordering the x-axis values

Okay so I have the Order column now, how do I make it sort by that column?

Community Support
Community Support

Re: Re-ordering the x-axis values

Hi @AlexCassin,

 

Please refer to the picture to sort the column by another coumn in the table.

2.PNG

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
AlexCassin Frequent Visitor
Frequent Visitor

Re: Re-ordering the x-axis values

Hmm, I seem to be doing something wrong. I've sorted by order but the range doesn't seem to change correctly, it jumps from 1 to 3... There is data there that should be before 3 but its further down. Please see the picture below (Had to black out sensitive information) but you can see that order is ticked in the dropdown and the numbers on the right jump from 1 to 3.tempsnip.png

Community Support
Community Support

Re: Re-ordering the x-axis values

Hi @AlexCassin,

 

Did you try to create visuals? By sorting by the order column. The x-axis values should be ordering accrodingly as you excepted If you had make the AgeRange column be sorted by order.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
AlexCassin Frequent Visitor
Frequent Visitor

Re: Re-ordering the x-axis values

Yes, nothing changed about the visual at all.

Capture.PNG

Community Support
Community Support

Re: Re-ordering the x-axis values

Hi @AlexCassin

 

Did you make the visual Sort by Agerange like the picture as below.

 

23.PNG

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
AlexCassin Frequent Visitor
Frequent Visitor

Re: Re-ordering the x-axis values

Aha! That did it! I thought t was already sorted by that so I didn't even think to check! Must've changed it when I was trying things myself! 

 

Thanks!

Helpful resources

Announcements
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors