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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Confusion with variabl...
Power Apps
Answered

Confusion with variables in Power App

(0) ShareShare
ReportReport
Posted on by 42

Hi all,

 

I have a Power App with 3 screens. 

 

Screen 1 - there is a button with OnSelect doing some stuff including this: 

Set(maxEntries,2);
Set(entryCount,0);

 

Screen 2 - there is an icon with OnSelect doing some stuff including this:

UpdateContext({entryCount:If(IsBlank(entryCount),1,entryCount+1)});

If(maxEntries-entryCount=0,UpdateContext({showTimer: true });UpdateContext({startTimer: true }););

Also a label which shows this:

"Entries remaining: " & If(maxEntries - entryCount = 1, "One more!", maxEntries - entryCount)

 

Screen 3 - again a button with OnSelect:

Clear(myCollection);
Navigate(Screen1);

 

My intended flow is like this. The user lands at screen 1 and maxEntries and entryCount variables are initialised. In screen 2 the user types into a textbox (he only has two attempts) and after the last attempt a countdown starts and after 10 seconds the user is redirected to Screen 3. Then a collection called myCollection is cleared and user is redirected to screen 1.

 

What should happen is the cycle starts again, but what happens is the label in screen 2 starts at 0 and goes negative indefinitely, so I cannot enforce the max of 2 entries in the second cycle.

 

I think the issue is related to the entryCount variable since UpdateContext somehow seems to update only in the scope of Screen 2 and not globally. Or smth like that...

 

Hopefully I managed to describe the situation adequately. Any insight / comment will be highly appreciated.

 

Thank you very much in advance.

Categories:
I have the same question (0)
  • Verified answer
    ManishSolanki Profile Picture
    15,091 Super User 2025 Season 2 on at

    Hi @Ts01 

     

    To update the global variable in Screen 2, pls use the below formula:

     

    Set(entryCount,If(IsBlank(entryCount),1,entryCount+1));

     

    replace the abovesaid formula with updatecontext statement. Hopefully it will fix the issue.

     

    Thanks

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • Ts01 Profile Picture
    42 on at

    Thank you @ManishSolanki so much!!! It worked perfectly!!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard