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 / Timer switching betwee...
Power Apps
Answered

Timer switching between countdown and counting up.

(0) ShareShare
ReportReport
Posted on by 68

Hi All,

Thanks for looking at my question.

It starts off easy. I want a timer that counts down from 12 mins to zero when the ON button is pressed but will count back up to 12 mins if the STBY button is pressed.

Mine will count down from 12 mins to zero, pause if I press STBY and continue to count down if ON is pressed again. What I want is if I press STBY that the timer immediately starts counting back up to 12 mins. 

 

timer.png

Timer Text =

If(timerComplete,
//Count up from 0 mins to 12 mins
Text(Time(0,(2),(Self.Value)/1000),"mm:ss"),
//Count down from 12 mins to 0 mins
Text(Time(0,0,(Self.Duration-Self.Value)/1000),"mm:ss"))

 

I'll continue to work on this and post if I find a solution.

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @SydEng 

    Change your STBY button OnSelect action to:

    UpdateContext({_dir: -1})

    And your On OnSelect action to:

    UpdateContext({_dir: 1})

    Then change your Timer Text property to:

    With({_maxDuration: 60* 12, _cnt: Coalesce(lclCount, 0) + _dir},
     UpdateContext({lclCount: If(_cnt<0, 0, _cnt>_maxDuration, _maxDuration, _cnt) })
    )

     

    This should provide what you are looking for.

     

    I hope this is helpful for you.

     

  • SydEng Profile Picture
    68 on at

    Dear RandyHayes,

    Thank you so much!!

    Yes, from a quick look I think you may have saved me more than a few hours of doing something that wouldn't end up as clean as your solution. 

    Kind regards, SydEng

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @SydEng 

    Happy to help!

  • SydEng Profile Picture
    68 on at

    @RandyHayes 

    Hi Randy,

    Ended up having limited time yesterday.

    When I tried it I received "Behaviour function" complaints, maybe because there's no text output?

    Your thoughts?

    SydEng

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Just adding what worked for me. 

    MoosaLaghari_0-1666522824614.png

    My Timer's Text Property:

    Text(Time(0, 0, -(Self.Value - 3000)/1000), "ss")

    And Duration:

    3000

     

    So it counts from 3 to 0 like, 03 > 02 > 01 > 00

     

    Hope it helps too.

     

    Thanx

     

  • SydEng Profile Picture
    68 on at
    Hi MoosaLaghari,
    Yes, that would work. Which is essentially the same as the standard count down timer of 

     

    Text(Time(0, 0, (Self.Duration - Self.Value)/1000), "ss")

     

    PREVIEW
    but what I wanted is if started with a timer counting up with a value of "x" and pressed a button the next value would be "x minus 1 sec". Let's say it was counting up and at 1:37. If I pressed the button the value becomes 1:36, 1:35, ....
     
    I did have success with creating a stopValue variable saving the Timer.Value on the OnSelect of the button and then the timer Text = Text(Time(0,2,((StopValue*2) - Self.Value) / 1000),"mm:ss") but this only works in one direction, I want it in both directions.
     SydEng
     
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi SydEng,

     

    Thank you, I think this standard count down you mentioned is rather more accurate.

     

    But what if you created two timers (countUp/countDown) and positioned both at same point, and then show/hide the count up or count down timers on your button click.

     

    MoosaLaghari

     

  • SydEng Profile Picture
    68 on at

    With some good manipulation you can use just the one timer but the problem is not only do I need to swap the timer to count up using the current time as a starting point. I also need to adjust the timer duration and all at the same time when timer.Value can only be a positive value! I'm convinced there's a way to do it. 

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 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard