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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jasmith866
Helper I
Helper I

Transform Datetime column to add an hour at query stage

I've managed to create a custom column which adds an hour to a datetime field by referencing it and adding + #duration(0,1,0,0)

 

What i'd like to do is instead transform the original column to add the hour there, as a lot of the rest of the report is driven by the first field and I'd rather not update all the references to a new vustom field - can this be done? Everything i've tried re: transform column hasn't worked

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jasmith866 ,

Sorry for my misunderstanding...

 

You could use the following in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtC31DdUMDSwMgAhpVgduKiRgqEhpqixgqGRlTG6qImCpZWpKVBcKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateTime = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetime}}),
    Custom1 = Table.TransformColumns(#"Changed Type",{"DateTime",each _+#duration(0,1,0,0)})
in
    Custom1

 

10.9.0.1.PNG
Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @jasmith866 ,

Sorry for my misunderstanding...

 

You could use the following in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtC31DdUMDSwMgAhpVgduKiRgqEhpqixgqGRlTG6qImCpZWpKVBcKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateTime = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetime}}),
    Custom1 = Table.TransformColumns(#"Changed Type",{"DateTime",each _+#duration(0,1,0,0)})
in
    Custom1

 

10.9.0.1.PNG
Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi @jasmith866 ,

 

According to my understand, you want to create a new column which add a hour based on the original DateTime column , right?

1.In Power Query -->Add a custom column using the M code as follows:

10.8.3.1.png

2.Use the following DAX formula to add a new calculate column:

Column =

[DateTime] + 1 / 24

 

The final result looks like this:

10.8.3.2.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

Thanks for your reply. Not quite - i'm looking to transform the original column, not create a new one

amitchandak
Super User
Super User

@jasmith866 , nor very create

 

New column = [column]+ #duration(0,1,0,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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