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
Anonymous
Not applicable

How to label the date/time on X axis of a monthly max value?

Hi all,

 

I am attempting to build a bar chart in Power BI that mirrors an excel table detailing the max hourly value of every month. The excel version looks like this ("HE" means "hour ending". This is the time component):

 

What i have right now in Power BI is this:

How do i convert the X axis to Date & time for every month? For example: Jan 29, 6:00AM; Feb 28th, 5:00AM, etc?

 

I appreciate any help provided. Thank you.

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi helmsbk,

You could try to use below M code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMU9JRMjcBEkaWukCerqElkO3hqmCmFKsTreSWmgTkWpiC5C10gTy4vClY3jexKDkDKGBmBFJhpgvko6lwLCjKhBlhaKoL5MIVGBkpxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"2019" = _t, max = _t, date = _t, HE = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each [date]&" "&(Text.Combine(List.RemoveNulls(List.Transform(Text.ToList([HE]),each if Value.Is(Value.FromText(_), type number) then _ else null)))&":00:00")),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type datetime}})
in
    #"Changed Type"

Then convert date format like below

465.PNG

Best Regards,
Zoe Zhi

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

2 REPLIES 2
Anonymous
Not applicable

My apologies, i did not explain my raw data table well enough. The excel file i showed above is what we are using now, but it is pulling from the same raw data as what i will be using in Power BI. I would like to move away from using that clunky excel file and substitute it with Power BI.

 

The chart you built is perfect, but i cannot recreate it. This is what the raw data table looks like in Power BI:

Capture v2.PNG

  • I have the date/time column formatted as "date/time" in the query tool. That current format is exactly what i need for the X axis.
  • I need the "Total rolling MW" column to show up how you did your table. Right now the "categorical" option under the X axis does not show up.

 

Here is how i have the data formatted in Visualizations currently:

Capture.PNG

 

Thank you for your help!

 

 

 

dax
Community Support
Community Support

Hi helmsbk,

You could try to use below M code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMU9JRMjcBEkaWukCerqElkO3hqmCmFKsTreSWmgTkWpiC5C10gTy4vClY3jexKDkDKGBmBFJhpgvko6lwLCjKhBlhaKoL5MIVGBkpxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"2019" = _t, max = _t, date = _t, HE = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each [date]&" "&(Text.Combine(List.RemoveNulls(List.Transform(Text.ToList([HE]),each if Value.Is(Value.FromText(_), type number) then _ else null)))&":00:00")),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type datetime}})
in
    #"Changed Type"

Then convert date format like below

465.PNG

Best Regards,
Zoe Zhi

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.