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 / NOT FOR THE FAINT OF H...
Power Apps
Unanswered

NOT FOR THE FAINT OF HEART: (RE)Calculate Time Durations... on the fly?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello PowerApps community,

 

I'm stuck here on something pretty complex. I hope I can explain it clearly here and we can come up with some ideas for how to tackle. 

 

Scenario:

- Users select an Event from dropdown

- A timestamp for Now() is generated

- User can adjust timestamp to actual for the activity and add comments as needed

- I also have some hidden fields that calculate the duration between the LAST submitted record and the CURRENT one

- User clicks "Add Event" button

- OnSelect of the "Add Event" button, Event, Timestamp and Duration are collected and displayed in a Gallery below

- This is all good as long as they record Events IN ORDER

 

ericonline_0-1611877959675.png

 

The Problem:

- The list of items in the Events dropdown is ~10-12

- If user adjusts a new Event Timestamp to be a time BEFORE the last Timestamp in the Collection, the Duration is off

  - Again, this is because the hidden helper fields calculate the Duration based on the LAST Timestamp in the Collection and the current Timestamp

 

Example of the issue:

 

ericonline_0-1611877695250.png

 

Questions:

- How would I lookup in the collection, where the current Event Timestamp should "fit", then calculate Duration?

 

Categories:
I have the same question (0)
  • zmorek Profile Picture
    3,272 on at

    I'm not sure I 100% understand, but I'll take a stab; what if you don't generate the Now() when the user selects the event, and then just make them enter the datetime? If they have the option to backdate something, just remove the convenience of having it auto-populate Now().

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thats a good thought. I thought about disallowing them to backdate.

    To accommodate:

    - They'd have to delete all Events in the Gallery until they reach a Timestamp less than the one they are trying to enter

    - Then recreate all the deleted events afterwards

    Pretty hard on them for making a simple mistake (missing an Event, wanting to be more accurate, etc.).
    I'm trying to find a simple way to "Insert" the Timestamp with correct Duration calculation.

  • zmorek Profile Picture
    3,272 on at

    What if instead of calculating duration based on the last submitted record and the current one, you calculate it off a fixed datetime? 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yeah, thats closer.

     

    Instead of a "fixed date", I need to measure from the Timestamp in the collection that is less than the one being added currently.

     

    The challenge is, the Duration of the record after the new Timestamp needs to be recalculated. Its now based of a new value instead of its original.

     

    For Example:

    - In my second screenshot above,

    - The "Fourth Event" entered becomes the "First Event" in the timeline

    - The previous "First Event" becomes the "Second Event" in the timeline

    - The now "Second Event"'s Duration must be recalculated from "-" to "60:00"

    - The now "First Event" Duration is the new baseline of "-"

    - If a new Timestamp is inserted between two existing Events (rather than the earliest in the timeline), two Durations need to be calculated.

    Hope that is clear, its challenging to explain. 🙂

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 94

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard