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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors