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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Freeseman
Helper II
Helper II

Date sort from 18:00 to 17:00

Hi All,

 

Is there a way to sort my date in 24h day from 18:00 start to 17:00 end and not from 00:00 to 23:00

So in other words like this...

Freeseman_1-1660049407457.png

I am trying to structure my X axis by hour but in a specific order. So by default Power BI would arrange my hours from 0 - 23

or it would kind of just mix them up as below.

Freeseman_0-1660049351800.png

The result i am trying to acheive is like this:

Freeseman_1-1660049407457.png

Please help me in the right direction to replicate the second visual

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Freeseman ,

 

Please try:

First, create a new column to help sort:

vjianbolimsft_1-1660633780556.png

 

Here is the M code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc/JDcAwCATAXnj7YRYfoRYr/bcRsY4Ev7E4Fp8jXZq4yduOaHCRCHbSgiBHcJMzOMiVYzt7n+AkvUREnPa7WRno1yi23KijDsxSWLWw64PReu2lgJ5HQ7MJyH/B/jveDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", Int64.Type}, {"Value", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Time]>=18 then [Time]-18 else [Time]+6),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}})
in
    #"Changed Type1"

Then use sort by column:

vjianbolimsft_2-1660633868312.png

Choose sort by time in the visual:

vjianbolimsft_3-1660634078990.png

Final output:

vjianbolimsft_4-1660634108257.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @Freeseman ,

 

Please try:

First, create a new column to help sort:

vjianbolimsft_1-1660633780556.png

 

Here is the M code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc/JDcAwCATAXnj7YRYfoRYr/bcRsY4Ev7E4Fp8jXZq4yduOaHCRCHbSgiBHcJMzOMiVYzt7n+AkvUREnPa7WRno1yi23KijDsxSWLWw64PReu2lgJ5HQ7MJyH/B/jveDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", Int64.Type}, {"Value", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Time]>=18 then [Time]-18 else [Time]+6),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}})
in
    #"Changed Type1"

Then use sort by column:

vjianbolimsft_2-1660633868312.png

Choose sort by time in the visual:

vjianbolimsft_3-1660634078990.png

Final output:

vjianbolimsft_4-1660634108257.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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