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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
M-M-P
Helper III
Helper III

Column calculation in Query Editor

Hi everyone

In the Query Editor I have a column with Timestamps and in another column I have a number.

See the picture below.

UTC Local 01.png

That number is the hour offset I want to plus into the timestamp. 

The result should look like this:

UTC Local 02.png

I can create a new column where I do the calculation with this command = [Timestamp] + #duration (0, [Hours Offset], 0.0)

But is it possible to do the calculation in the original column?

 

Thanks in advance

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @M-M-P 

 

Credit to @ImkeF for this method using Table.ReplaceValue (post here)

 

Rather than adding a new column, put this in the formula bar (where PreviousStep is the name of your previous query step):

 

= Table.ReplaceValue(PreviousStep, each [Timestamp], each [Timestamp]+#duration(0,[Hours Offset],0,0), Replacer.ReplaceValue, {"Timestamp"})

 

This has the side-effect of discarding the column type of Timestamp.

 

To avoid losing the column type, you can use this code instead:

 

= Value.ReplaceType(Table.ReplaceValue(PreviousStep, each [Timestamp], each [Timestamp]+#duration(0,[Hours Offset],0,0), Replacer.ReplaceValue, {"Timestamp"}), Value.Type(PreviousStep))

 

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @M-M-P 

 

Credit to @ImkeF for this method using Table.ReplaceValue (post here)

 

Rather than adding a new column, put this in the formula bar (where PreviousStep is the name of your previous query step):

 

= Table.ReplaceValue(PreviousStep, each [Timestamp], each [Timestamp]+#duration(0,[Hours Offset],0,0), Replacer.ReplaceValue, {"Timestamp"})

 

This has the side-effect of discarding the column type of Timestamp.

 

To avoid losing the column type, you can use this code instead:

 

= Value.ReplaceType(Table.ReplaceValue(PreviousStep, each [Timestamp], each [Timestamp]+#duration(0,[Hours Offset],0,0), Replacer.ReplaceValue, {"Timestamp"}), Value.Type(PreviousStep))

 

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

@OwenAuger 
Thanks a lot, it does exactly what I wanted 😄

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.