cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Calculating duration between onselect

Hi all I have calculated the duration between onselect in powerapps by calculating the difference between: the now() at the first onselect and the now() at the second onselect.

 

These two times are stored in SharePoint using patch function and a calculated column then calculates the difference.

 

I noticed that doing this way doesn't always capture the right duration because the first onselect now() often doesn't get recorded. 

 

Is there another solution to getting the duration?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Calculating duration between onselect

Hi @noneother ,

 

Try this:

UpdateContext({UpdateStartTime: Now()}); Patch('Consumer Sample for Survey FINAL', lookup('Consumer Sample for Survey FINAL',ID=Gallery1.Selected.ID), {'Call Started': Label13.Text,'Call Ended': Now()})

 
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

8 REPLIES 8
Highlighted
Super User III
Super User III

Re: Calculating duration between onselect

Are you using a Timer? Can you give more detail on your current Approach

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Super User III
Super User III

Re: Calculating duration between onselect

Hi @noneother ,

 

You are almost doing the right approach, please make the below changes to make it perfect:

  1. Create 2 labels on the screen (you can make their visible false once you are sure about the output)
  2. Set the label 1 with Now() for the onSelect of the button and the label 2 with Now() for the second of the button
  3. Now use the text on the label as part of your Patch 
    Note: Text on the Label will not change unless you reload the screen 😊 so you will the expected values to be stored in the list.

I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
Highlighted
Helper I
Helper I

Re: Calculating duration between onselect

@KrishnaV 

 
 

Unfortunately I couldn't get this to work.

 

Label with the following formula in Text: UpdateStartTime

 

My button forumla for the onselect:

UpdateContext({UpdateStartTime: Now()}); Patch('Consumer Sample for Survey FINAL', Gallery1.Selected, {'Call Started': Label13})

The button formula returns: unknown error

Highlighted
Helper I
Helper I

Re: Calculating duration between onselect

eka24 no timer. just using the now( ) to calculate duration between two time stamps. i thought this way would be quicker but it's hit or miss

Highlighted
Super User III
Super User III

Re: Calculating duration between onselect

Hi @noneother ,

 

Try this:

UpdateContext({UpdateStartTime: Now()}); Patch('Consumer Sample for Survey FINAL', lookup('Consumer Sample for Survey FINAL',ID=Gallery1.Selected.ID), {'Call Started': Label13.Text,'Call Ended': Now()})

 
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

Highlighted
Helper I
Helper I

Re: Calculating duration between onselect

@KrishnaV thank you. seems to be working.

I don't know why this is working better using a label rather than direct patching the now() to my SharePoint list but it seems to do the job and more responsive.

Highlighted
Super User III
Super User III

Re: Calculating duration between onselect

Hi @noneother ,

 

I am really glad it is working for you. As I said before now() get the instant time.

Since the issue is resolved, do you mind marking it is a solution so that the new members of the community will make use of it?

 

I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
Highlighted
Helper I
Helper I

Re: Calculating duration between onselect

I know what now() does of course just not sure why writing a now to a label is AND then patching is more efficient than patching now() directly.

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,664)