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
Applicable88
Impactful Individual
Impactful Individual

PowerBi server weekday vs. local weekday

Hello,

 

I need a function to return the day number of the real local time. My offset to the server are two hours. I use this for my calculated column which shows me the number of today. I created it and load data to double check if I get it right. value: Date.DayOfWeek(DateTime.FixedLocalNow(), Day.Sunday)

It works as long the lagging UTC Time from the server is on the same day, but not in the midnight time. 

I use it in  a nested  if-statement for a Friday condition: if Date.DayOfWeek([Orderdate]) = 5 then........else..

Since its not a date and just a number, how to get it returns 5 even after thursday midnight to Friday, when server time is still two hours lagging and at day 4?

A combination with DateTimeZone.SwitchZone didn't return 5 as well, but only error.

Thank you in advance.

Best. 

 

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Applicable88 

 

Not sure if I understand it correctly, so you want to know the weekday of server time and it is fixed 2 hours lagging, like this?

 

Date.DayOfWeek((DateTime.FixedLocalNow()- #duration(0,2,0,0)), Day.Sunday)

 

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Applicable88 

 

Have you tried @Vera_33 's solution? It should work. You can use it in your if-statement then. Kindly accept it as the solution if it helps solve this problem. If not, share more details about your expected result.

 

Regards,
Community Support Team _ Jing

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Applicable88 

 

Not sure if I understand it correctly, so you want to know the weekday of server time and it is fixed 2 hours lagging, like this?

 

Date.DayOfWeek((DateTime.FixedLocalNow()- #duration(0,2,0,0)), Day.Sunday)

 

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.

Top Solution Authors
Top Kudoed Authors