Forum Discussion

Applicable88's avatar
Applicable88
Impactful Individual
5 years ago
Solved

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. 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    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)

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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)

     

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi Applicable88 

     

    Have you tried Anonymous '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