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

Displaying Last Refresh Time in PST

Hi, after publishing my PBI report to the web, the Last Refresh = #table(type table[LastRefresh=datetime], {{DateTime.LocalNow()}}) time stamp in PBI service is showing UTC time (which is 8 hrs ahead of PST).

I looked for several solutions online, including the API code below (which I pasted in Advanced Editor) - but it gave me the error (screenshot attached). What is the easiest code to show the PST time in the report after it's published to PBI service? Thanks.Capture.JPG

 

CODE:

let
Source = Web.Page(Web.Contents("http://www.timeapi.org/pst")),
Data0 = Source{0}[Data],
Children = Data0{0}[Children],
Children1 = Children{1}[Children],
#"Removed Other Columns" = Table.SelectColumns(Children1,{"Text"}),
#"Inserted Last Characters" = Table.AddColumn(#"Removed Other Columns", "Last Characters", each Text.End(Text.From([Text], "en-US"), 6), type text),
#"Changed Type2" = Table.TransformColumnTypes(#"Inserted Last Characters",{{"Text", type datetimezone}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type2",":00",".0",Replacer.ReplaceText,{"Last Characters"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",":30",".5",Replacer.ReplaceText,{"Last Characters"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value1",{{"Last Characters", type number}, {"Text", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "LastRefresh", each [Text]+#duration(0,Number.From([Last Characters]),0,0)),
#"Removed Other Columns1" = Table.SelectColumns(#"Added Custom",{"LastRefresh"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns1",{{"LastRefresh", type datetime}})
in
#"Changed Type"

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This is what I ended up doing.

I used the original code: #table(type table[LastRefresh=datetime], {{DateTime.LocalNow()}})

Then I created a measure: Last Refresh_PST = MIN('Last Refresh'[LastRefresh])-7/24

That seemed to work after I published to PBI service.

Thanks!

 

View solution in original post

4 REPLIES 4
az38
Community Champion
Community Champion

Hi @Anonymous 

if you are sure in -8 hours offset try to use

DateTimeZone.SwitchZone(DateTimeZone.LocalNow(), -8)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

This is what I ended up doing.

I used the original code: #table(type table[LastRefresh=datetime], {{DateTime.LocalNow()}})

Then I created a measure: Last Refresh_PST = MIN('Last Refresh'[LastRefresh])-7/24

That seemed to work after I published to PBI service.

Thanks!

 

Hi @Anonymous ,

Thanks for sharing your solution. Could you please mark your post as Answered? It will help others in the community find this solution easily if they face the same problem with you. Thank you.

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

It did not work. It's giving me an error but doesn't tell me what, and the visualization is (Blank). Thanks.

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.