Forum Discussion
Sort by column not working
- Anonymous2 years ago
Hi sdavidson ,
According to your statement, I think you are using "Continuous" in X-aixs Type. I think you can select “Categorical” in X-axis Type.
However this will expand your X-axis in your visual and show all time. Result is as below.
You can add a new Timegroup column and New Index for this group in Power Query Editor.
New Time Table:
let Source = List.Times(#time(18, 0, 0), 1440, #duration(0, 0, 1, 0)), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Time"}}), #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time", type time}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index for Time", 1, 1, Int64.Type), #"Inserted Hour" = Table.AddColumn(#"Added Index", "TimeGroup", each #time( Time.Hour([Time]),0,0)), #"Grouped Rows" = Table.Group(#"Inserted Hour", {"TimeGroup"}, {{"Rows", each _, type table [Time=nullable time, Index for Time=number, TimeGroup=time]}}), #"Added Index1" = Table.AddIndexColumn(#"Grouped Rows", "Index for TimeGroup", 1, 1, Int64.Type), #"Expanded Rows" = Table.ExpandTableColumn(#"Added Index1", "Rows", {"Time", "Index for Time"}, {"Rows.Time", "Rows.Index for Time"}), #"Reordered Columns" = Table.ReorderColumns(#"Expanded Rows",{"TimeGroup", "Index for TimeGroup", "Rows.Time", "Rows.Index for Time"}), #"Renamed Columns1" = Table.RenameColumns(#"Reordered Columns",{{"Rows.Time", "Time"}, {"Rows.Index for Time", "Index for Time"}}), #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Index for Time", Int64.Type}, {"TimeGroup", type time}}) in #"Changed Type1"Sort TimeGroup by Index for TimeGroup and create a the visual. Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi sdavidson ,
According to your statement, I think you are using "Continuous" in X-aixs Type. I think you can select “Categorical” in X-axis Type.
However this will expand your X-axis in your visual and show all time. Result is as below.
You can add a new Timegroup column and New Index for this group in Power Query Editor.
New Time Table:
let
Source = List.Times(#time(18, 0, 0), 1440, #duration(0, 0, 1, 0)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Time"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time", type time}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index for Time", 1, 1, Int64.Type),
#"Inserted Hour" = Table.AddColumn(#"Added Index", "TimeGroup", each #time( Time.Hour([Time]),0,0)),
#"Grouped Rows" = Table.Group(#"Inserted Hour", {"TimeGroup"}, {{"Rows", each _, type table [Time=nullable time, Index for Time=number, TimeGroup=time]}}),
#"Added Index1" = Table.AddIndexColumn(#"Grouped Rows", "Index for TimeGroup", 1, 1, Int64.Type),
#"Expanded Rows" = Table.ExpandTableColumn(#"Added Index1", "Rows", {"Time", "Index for Time"}, {"Rows.Time", "Rows.Index for Time"}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded Rows",{"TimeGroup", "Index for TimeGroup", "Rows.Time", "Rows.Index for Time"}),
#"Renamed Columns1" = Table.RenameColumns(#"Reordered Columns",{{"Rows.Time", "Time"}, {"Rows.Index for Time", "Index for Time"}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Index for Time", Int64.Type}, {"TimeGroup", type time}})
in
#"Changed Type1"
Sort TimeGroup by Index for TimeGroup and create a the visual. Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks! Switching to categorical has sorted the x axis issue.
Sorry im pretty new to BI, where do i enter the code for the time group table?