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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Can someone help me convert this power query function to DAX? (Changing UTC to NZT)

Hi,

 

I need to change UTC to NZT in Dax. I can't do it in PowerQuery because I'm using DirectQuery rather than import and it won't work unless I import my tables which I don't want to do.

 

Essentially I need to convert timestamps from GMT to UTC and found this. Can someone help me convert it to DAX?

 

(datetimecolumn as datetime) =>

let

date = DateTime.Date(datetimecolumn),
time = DateTime.Time(datetimecolumn),
firstSundayOfApril = Date.StartOfWeek(#date(Date.Year(date), 4, 7), Day.Sunday),
LastSundayOfSeptember = Date.StartOfWeek(#date(Date.Year(date), 9, 30), Day.Sunday),

isSummerTime =	(date = LastSundayOfSeptember and time >= #time(1,0,0))
	        or
		(date > LastSundayOfSeptember and date < firstSundayOfApril) 
		or 
		(date = firstSundayOfApril and time >= #time(1,0,0)),


timeZone = (12 + Number.From(isSummerTime))*1,

NZT = 
            DateTime.From(date) 
            + #duration(0,Time.Hour(time),Time.Minute(time),Time.Second(time))  
            + #duration(0, timeZone, 0, 0)

in
    NZT
1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You are adding a DAX calculated column like this?

 

NZT_dt = 
VAR CurY =
    YEAR ( yourTable[OriginDT] )
VAR StartST =
    DATE ( CurY, 4, 7 ) - WEEKDAY ( DATE ( CurY, 4, 7 ), 1 ) + 1
VAR EndST =
    DATE ( CurY, 9, 30 ) - WEEKDAY ( DATE ( CurY, 9, 30 ), 1 ) + 1
RETURN
    IF (
        yourTable[OriginDT] > StartST
            && yourTable[OriginDT] < EndST,
        yourTable[OriginDT] + ( 13 / 24 ),
        yourTable[OriginDT] + ( 12 / 24 )
    )

 

?

 

Vera_33_0-1626157036499.png

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you!

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You are adding a DAX calculated column like this?

 

NZT_dt = 
VAR CurY =
    YEAR ( yourTable[OriginDT] )
VAR StartST =
    DATE ( CurY, 4, 7 ) - WEEKDAY ( DATE ( CurY, 4, 7 ), 1 ) + 1
VAR EndST =
    DATE ( CurY, 9, 30 ) - WEEKDAY ( DATE ( CurY, 9, 30 ), 1 ) + 1
RETURN
    IF (
        yourTable[OriginDT] > StartST
            && yourTable[OriginDT] < EndST,
        yourTable[OriginDT] + ( 13 / 24 ),
        yourTable[OriginDT] + ( 12 / 24 )
    )

 

?

 

Vera_33_0-1626157036499.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors