Forum Discussion
AlexCassin
7 years agoFrequent 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. This is what I have but I want the order to be "< 1 Week", "1 Week - 1 Month", "1...
- 7 years ago
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"
For more details, please check the pbix as attached.Regards,
Frank
v-frfei-msft
7 years agoCommunity Support
AlexCassin
7 years agoFrequent Visitor
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!