Forum Discussion
Refresh time on visual
- Anonymous5 years ago
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)Best Regards,
Jay
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
Thanks for help. After publishing it is showing me UTC time , how can i subtract 4 hours? any idea
- AnkitKukreja5 years agoSuper User
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
- adnankabina5 years agoHelper II
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?
- AnkitKukreja5 years agoSuper User
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