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.
Hi Team,
I am using below codeto get the latest refresh date of Power BI report , this gives proper time in normal days ,but during Daylight saving Time , it didn't change the time.
Is there any way where M code can handle it automatically ?
let
#"LAST_REFRESH_DATE" = #table(type table[#"Last refresh date"=text],{{DateTimeZone.ToText(DateTimeZone.ToLocal(DateTime.AddZone(DateTime.LocalNow(),0)),"dd/MM/yyyy hh:mm")}}),
#"Added Custom" = Table.AddColumn(LAST_REFRESH_DATE, "Custom", each DateTimeZone.SwitchZone(DateTime.LocalNow()))
in
#"Added Custom"
Solved! Go to Solution.
Hi @Anonymous ,
I recommend to create a measure as below to get the latest refresh time instead of M code in power query.
Latest time = Now()
So finally this problem got resolved after lot many efforts 🙂
Posting the code , if any one is facing similar issue . This might help.
Below is the code:
What we are doing basically is to find out the last sunday of March and Octor month and if current datetime falls in that add 1 hour , else display as it is .
let
UTCOffset = 0,
Local_Time = DateTimeZone.FixedLocalNow(),
CurrentYear = Date.Year( DateTimeZone.SwitchZone( Local_Time,UTCOffset)),
DST_Start = Date.StartOfWeek(#datetimezone( CurrentYear,3,31,0,0,0,UTCOffset,0),Day.Sunday) + #duration(0,2,0,0),
DST_End = Date.StartOfWeek( #datetimezone( CurrentYear, 10,31,0,0,0, UTCOffset+1,0),Day.Sunday) + #duration(0,2,0,0),
#"CurrentDate" = Date.From(Local_Time+ #duration(0,UTCOffset,0,0)),
DST_Start1=Date.From(DST_Start+ #duration(0,UTCOffset,0,0)),
DST_End1=Date.From(DST_End+ #duration(0,UTCOffset,0,0)),
#"TimeOffsetinHours"= if #"CurrentDate">= DST_Start1 and #"CurrentDate" <= DST_End1
then (UTCOffset) + 1
else UTCOffset,
#"LAST_REFRESH_DATE" = #table(type table[#"Last refresh date"=text],{{DateTimeZone.ToText(DateTimeZone.ToLocal(DateTime.AddZone(DateTime.FixedLocalNow(),-TimeOffsetinHours)),"dd/MM/yyyy HH:mm")}})
in
#"LAST_REFRESH_DATE"
Thanks,
Megha Vaidya
Hi @Anonymous ,
I recommend to create a measure as below to get the latest refresh time instead of M code in power query.
Latest time = Now()
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |