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

Every 5 seconds to display a random single digit

HI Gurus, 

 

Spent about 12 hours but not figuring out how to achieve this. Hope you can help.

I am writing a simple app to display a single digit (1-9) on the label every 5 seconds. So I use a time control and use Rand function. 

I setup the label.text as below (Interval =5000)

If(Timer3.Value/Interval<1, 2,If(Timer3.Value/Interval<2, 7,If(Timer3.Value/Interval<3, 1, If(Timer3.Value/Interval<4, 9, If(Timer3.Value/Interval<5, 6, If(Timer3.Value/Interval<6, 8, 5))))))

I wanting to put Round(rand()*10, 0) in place instead of now the static values like 2, 7, 1,....

However when I do, every single milli-second, it trigs the rand function and my label you can imagine keeps changing/flashing.

 

Any good idea we can achieve this simple request? Thanks in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

Re: Every 5 seconds to display a random single digit

Hi @Derek5 

Please find the attache app for your requirement.

Steps 1  - Select the Screen and Set the Onvisible Properties - 

UpdateContext({RestartTimer:true});

Step 2 - Add the Timer Control and and set the OnTimerEnd Properties like below.

UpdateContext({RestartTimer:false});
UpdateContext({RandomValue:Round(Rand()*10, 0)});
UpdateContext({RestartTimer:true});

Step 3- Set the Timer AutoStart Properties like below

RestartTimer

 

Thanks,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
Highlighted
Memorable Member
Memorable Member

Re: Every 5 seconds to display a random single digit

Hi @Derek5 

Please find the attache app for your requirement.

Steps 1  - Select the Screen and Set the Onvisible Properties - 

UpdateContext({RestartTimer:true});

Step 2 - Add the Timer Control and and set the OnTimerEnd Properties like below.

UpdateContext({RestartTimer:false});
UpdateContext({RandomValue:Round(Rand()*10, 0)});
UpdateContext({RestartTimer:true});

Step 3- Set the Timer AutoStart Properties like below

RestartTimer

 

Thanks,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Every 5 seconds to display a random single digit

it is awesome. 

thank you so much.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Come join us today! Find your favorite faces from the community presenting at the Power Platform Community Conference!

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

Top Solution Authors
Top Kudoed Authors
Users online (3,568)