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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ManoukUBN
Frequent Visitor

How to display current time in your report using a measure, taking summer/winter time into account

Hi everyone!

 

I recently wrote a DAX script for my PowerBI report's landing page to display the current time, but I quickly ran into the issue of taking into account the summer/winter time difference in Central-EU as the powerBI service always takes UTC as the current time. I searched far and wide for anything similar, and only found a time last-refreshed built in Power Query, which wouldn't produce the current time (unless you refresh every minute, hahaha). I thought I'd share it, in case anyone else would want to do the same 🙂

 

Here's the code, put into a measure:

 

Tijd = 
var now =
    NOW()

var beginsummertime =
    DATE(YEAR(NOW()), 3, 31) - WEEKDAY(DATE(YEAR(NOW()), 3, 31), 2) + 3/24

var beginwintertime =
    DATE(YEAR(NOW()), 10, 31) - WEEKDAY(DATE(YEAR(NOW()), 10, 31), 2) + 3/24

var timezonediff =
    IF(now > beginsummertime && now < beginwintertime,
        2/24,
        1/24
    )

RETURN
now + timezonediff

 

This specific piece of code is made for the Dutch summer and winter timezones (CEST and CET), which change on the last sunday of March and October at 3 AM. Note that it's far from perfect, as it only re-calculates once the page is re-opened or refreshed. But it's the closest I could find to calculating the current time.

 

If you have any questions, comments or tips please let me know!

1 ACCEPTED SOLUTION
Mahesh0016
Super User
Super User

@ManoukUBN  I hope this helps you. Thank You
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hdJhDoMgDAXgqxD/bguvLSWhVzHe/xorwhDnzBJ/8flesXFdF+ZIiAyWwGRJLVF4AAYs23NdBBGlMcEERjgxRUjlFEhtP3dWf3FnOKfGqNHGI+2DoT0N49rvnC+zPa2V62waaS8n6kwG+Qzl3GMawKOVL61aW/0hdZa5FZ2zSfYCZxqsBxdT+MZOX5QOTqalzZ7L2z5y8EPy25XwOpUPJiMffypHPlhN2YS/9jHxtfwHz+X/mdt/cMdyw9sb", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetimezone}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "UTC DateTime", each DateTimeZone.ToUtc([Date])),
    #"Added Custom2" = Table.AddColumn(#"Added Custom", "Last Sunday of March", each Date.StartOfWeek(
    #date(
        Date.Year([UTC DateTime]),
        03, 
        31
    ), 
    Day.Sunday
)),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Last Sunday of Oct", each Date.StartOfWeek(
    #date(
        Date.Year([UTC DateTime]),
        10,
        31
    ), 
    Day.Sunday
)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom3", "AEST Daylight", each if 
DateTimeZone.RemoveZone([UTC DateTime]) < [Last Sunday of Oct] & #time(0,0,0)
and
DateTimeZone.RemoveZone([UTC DateTime]) > [Last Sunday of March] & #time(0,0,0)

then
DateTimeZone.SwitchZone([UTC DateTime],+2,0)

else
DateTimeZone.SwitchZone([UTC DateTime],+1,0))
in
    #"Added Custom1"

View solution in original post

1 REPLY 1
Mahesh0016
Super User
Super User

@ManoukUBN  I hope this helps you. Thank You
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hdJhDoMgDAXgqxD/bguvLSWhVzHe/xorwhDnzBJ/8flesXFdF+ZIiAyWwGRJLVF4AAYs23NdBBGlMcEERjgxRUjlFEhtP3dWf3FnOKfGqNHGI+2DoT0N49rvnC+zPa2V62waaS8n6kwG+Qzl3GMawKOVL61aW/0hdZa5FZ2zSfYCZxqsBxdT+MZOX5QOTqalzZ7L2z5y8EPy25XwOpUPJiMffypHPlhN2YS/9jHxtfwHz+X/mdt/cMdyw9sb", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetimezone}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "UTC DateTime", each DateTimeZone.ToUtc([Date])),
    #"Added Custom2" = Table.AddColumn(#"Added Custom", "Last Sunday of March", each Date.StartOfWeek(
    #date(
        Date.Year([UTC DateTime]),
        03, 
        31
    ), 
    Day.Sunday
)),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Last Sunday of Oct", each Date.StartOfWeek(
    #date(
        Date.Year([UTC DateTime]),
        10,
        31
    ), 
    Day.Sunday
)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom3", "AEST Daylight", each if 
DateTimeZone.RemoveZone([UTC DateTime]) < [Last Sunday of Oct] & #time(0,0,0)
and
DateTimeZone.RemoveZone([UTC DateTime]) > [Last Sunday of March] & #time(0,0,0)

then
DateTimeZone.SwitchZone([UTC DateTime],+2,0)

else
DateTimeZone.SwitchZone([UTC DateTime],+1,0))
in
    #"Added Custom1"

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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