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
Anonymous
Not applicable

Power Query - Order of hours in day - EU Summer and Winter time

Hi, I have trouble with changing time in EU from Summer to Winter time and back in Power Query.

 

I need get hour from datetime. It is simple because I can use "Time.Hour([From])". The problem is in two days in year when the time is changing from summer to winter and back (for example in 2019 it is day 31.3.2019 and 27.10.2019).

27.10.2019 - I get 2 similar values for time 02:00:00

31.3.2019 - I don't get value for time 02:00:00

 

Below is picture, where is my "goal". From each datetime I need to get hour respectively order of hours in day.

I can't use something like in sql "row_number() over (partition by date order by time)" because I do not have to have all hours of the day available.

 

"Because of" in picture below is table, which is my final goal, but it is second step. The first is get hours from datetime, I think.

 

Thank you

 

order hours in day.JPG

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I think, that I have it.

 

this is formula for return right value from datetime in my local zone.

 

if (DateTime.Date([From]) = Date.StartOfWeek(#date(Date.Year([From]),11,1),Day.Sunday) 
and DateTimeZone.ZoneHours([From]) = 1
) 
then Time.Hour([From])+1
else if (DateTime.Date([From]) = Date.StartOfWeek(#date(Date.Year([From]),4,1),Day.Sunday)
and DateTimeZone.ZoneHours([From]) = 2

)
then Time.Hour([From])-1
else Time.Hour([From])

View solution in original post

1 REPLY 1
Anonymous
Not applicable

I think, that I have it.

 

this is formula for return right value from datetime in my local zone.

 

if (DateTime.Date([From]) = Date.StartOfWeek(#date(Date.Year([From]),11,1),Day.Sunday) 
and DateTimeZone.ZoneHours([From]) = 1
) 
then Time.Hour([From])+1
else if (DateTime.Date([From]) = Date.StartOfWeek(#date(Date.Year([From]),4,1),Day.Sunday)
and DateTimeZone.ZoneHours([From]) = 2

)
then Time.Hour([From])-1
else Time.Hour([From])

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.