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
adnankabina
Helper II
Helper II

Refresh time on visual

I want to show Estern time on my visual. I have schedule for every 2 hours to refresh my data.  what I did on measure

Last Refreshed Time = UTCNOW()-TIME(4,0,0)

It is showing fine but it should stay same time until next refresh is done.  Below pic shows it refreshed at 6pm eastern time. If user goes to on 6:45pm and try to refreh from menue as show in pic should not change it.

 
 

adnankabina_0-1603588741781.png

 

 

 

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @adnankabina ,

 

In your scenario, you should use Calculated Column or M Query instead of Measure.

The former will refresh time after the dataset was refreshed, the latter will refresh time after the page was refreshed.

For calculated column, right click on the table and create a new column using your formula.

For M Query, open query editor and add custom column with below formula.

DateTime.LocalNow() + #duration(0,4,0,0)

1.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

I appreciate this entire thread of discussion, but it seems to be taking the System date (LocalNow) and adding it to the report.  My question is this:  I want the report to show the last date/time the report was refreshed, and “date/time” refers to the Refresh time set in the Gateway settings for refresh.  I know when that is supposed to be, because the report generating person, I set that date and time.  However, the consumer of the report does not necessarily know that and then it would be convenient to have a measure (or calculated column or…) that automatically shows when the actual last refresh date/time was so that the consumer is reassured that they are looking at “current” data.  I was looking at wrong a measure, but how do I access that date/time, set up in the Gateway settings, and integrate that with the report.??

v-jayw-msft
Community Support
Community Support

Hi @adnankabina ,

 

In your scenario, you should use Calculated Column or M Query instead of Measure.

The former will refresh time after the dataset was refreshed, the latter will refresh time after the page was refreshed.

For calculated column, right click on the table and create a new column using your formula.

For M Query, open query editor and add custom column with below formula.

DateTime.LocalNow() + #duration(0,4,0,0)

1.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
AnkitKukreja
Super User
Super User

Hi @adnankabina 

 

I believe you're on the right track, but would you mind creating the same in Query Editor. 
Please use Blank query and write = DateTime.LocalNow(). 

 

Please refer to the below link for reference. it works fine for me and time only changes when I refresh the model or it's on schedule refresh.

https://www.youtube.com/watch?v=oN6mOmEruOQ

 

Hope it helps.

 

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.
Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

Thanks for help. After publishing it is showing me UTC time , how can i subtract 4 hours? any idea

Hi @adnankabina 

 

Yes, please use DateTime.From ( [DateTime] ) + #duration(0, +5,0,0)

Note : +5 is utc to my time zone (so change as per your need). And [DateTime] is my date time column already availbale.

 

 

Thanks,

Ankit

If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.
Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

Hi AnkitKukreja,

 

Should I do in blank query or create a measure. I didnt get you.

 

This is what I did in blank query but go error.

= DateTime.From ( [DateTime] ) + #duration(0, +5,0,0)

 

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

Hi @adnankabina 

 

As you would have created your timestamp column by using blank query earlier, where you were getting time which was off by 4 hours. In the same table use this query by adding custom column.

 

Or in the same query use the below code, by deleting your full code in advance editor of this table and replace it by below code.

 

let
Source = DateTime.LocalNow(),
#"Converted to Table" = #table(1, {{Source}}),
#"Inserted Date" = Table.AddColumn(#"Converted to Table", "Date", each DateTime.Date([Column1]), type date),
#"Inserted Time" = Table.AddColumn(#"Inserted Date", "Time", each DateTime.Time([Column1]), type time),
#"Renamed Columns" = Table.RenameColumns(#"Inserted Time",{{"Column1", "DateTime"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "DateTime MyZone", each DateTime.From ( [DateTime] ) + #duration(0, +5,0,0))
in
#"Added Custom"

 

Or you can just add custom column in your current table and use my last m code that I shared.

 

Thanks,

Ankit

If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.
Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

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.

Top Solution Authors
Top Kudoed Authors