Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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!
Solved! Go to Solution.
@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"
@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"
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |