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
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
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.

Top Solution Authors