web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Duration calculated in...
Power Apps
Answered

Duration calculated in Gallery not updated

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a gallery in Power App that shows a list of incidents. I want to show how long ago the incident was opened.

I have a timer on the screen that updates a context variable every second. That works well, when I show the value of the variable in a label, I see the current time increasing every second.

 

In my Gallery, the value I show is Datadiff(StartDate, MyContextVariable, Minutes). In theory, I believe this should show and increasing number of minutes. However it looks like my calculation take the value of the context variable at "some" point and never updates it?

 

Any idea on how to make that work?

Categories:
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

    How do you initialize and update the MyContextVariable within your app? Could you please share a bit more about the formula?

    Do you want to calculate the duration of the incident from the Start Date to Now (current time)?

    I have made a test on my side, and don't have the issue that you mentioned. Please take a try with the following workaround:11.JPG

     

    12.JPG

     

    13.JPG

    Within the Gallery, set the Text property of the Duration Label control to following:

    DateDiff(ThisItem.Created, MyContextVariable, Minutes)

     

    Set the Duration property of the Timer control (Timer1) to following:

    1000

    Set the Repeat property and AutoStart property of the Timer control (Timer1) to following:

    true

    Set the OnTimerEnd proeprty of the Timer control (Timer1) to following:

    Set(MyContextVariable, Now())

    Note: Please use global variable (using Set() function) to store your MyContextVariable value rather than Context variable.

     

    Please check the following attached GIF screenshot for more details:

     

    Best regards,

    Kris

    Test.gif
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for you answer, 

     

    I managed to make it work since then. I believe my solution was very close to yours.

    As of now the only difference is that the time updates a context variables, a Label shows the context files and the gallery uses the Label.text to make all calculations. That works and I use the timer label as a watch which is usefull, my application being used for a very time sensitive matter.

     

    Thanks

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

    Have you solved your problem?

    If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved for other users.

    In addition, I think the solution I provide could also achieve your needs, please take a try with it.

     

    Best regards,

    Kris

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 383 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard