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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Applicable88
Impactful Individual
Impactful Individual

M-formula for the Server offset

Hello,

 

since the server runs in UTC i have 2 hours difference. The problem is that I have a calculation running for specific days. I used the a formula to offset the hours: Time.Hour(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),2,0))

 

But I also have a date problem, for example now in my local time its actually 1 o'clock in the morning and its Friday. The server displays 11PM but is still on Thursday. So in my very long m formula I also have a condition for when weeknumber = 5 and so fourth. 

So since the report still thinks its Thursday these values won't be displayed. 

I tried this: 

Time.Hour(DateTimeZone.SwitchZone(Date.From(DateTime.LocalNow()),2,0))

But I got error.  I want a date to return, not time. 

I also need to correct when its really Friday around the midnight range:

Date.DayOfWeek(DateTime.FixedLocalNow(), Day.Sunday)

 

Anyone has an idea? Thank you very much in advance.

 

Best. 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

You should be able to use this as your core expression and then wrap it in whatever you need to get your desired results.

 

= DateTime.LocalNow() + #duration(0,2,0,0)

 

For example, if you wrap it in Date.From, you will get tomorrows date (if it is >10 PM).

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

1 REPLY 1
mahoneypat
Microsoft Employee
Microsoft Employee

You should be able to use this as your core expression and then wrap it in whatever you need to get your desired results.

 

= DateTime.LocalNow() + #duration(0,2,0,0)

 

For example, if you wrap it in Date.From, you will get tomorrows date (if it is >10 PM).

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors