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 / How to set a variable ...
Power Apps
Answered

How to set a variable in a gallery when an app starts

(0) ShareShare
ReportReport
Posted on by 364

Hi all, 

 

I have an app with a gallery on it's second page. This gallery displays all submissions to a SharePoint site, and the first page of my app shows 3 counts for each item on the SharePoint (each count is for a status type). I am wondering if there is a way to set the variable on my gallery when the app starts, so that the labels with the count function are showing the actual numbers, and not all 0's.

 

I can include images or try to explain the issue in greater detail if needed. If anyone knows how I might be able to do this, I would greatly appreciate it.

 

Capture.PNG first page with 3 labels

Capture1.PNG formula in a button that sets the variable to show all SharePoint records

Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Write your initialization code on the App.OnStart property

  • Aurora Profile Picture
    364 on at

    @zmansuri 

     

    UpdateContext can't be used in the OnStart property of an app, so I don't really know what to write to get the result I want. The variable is only on the page with the gallery, so I guess I need to either change that or control the gallery when the app starts up. 

     

    Any suggestions? 

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Why can't you use global variable Set?

  • Verified answer
    Aurora Profile Picture
    364 on at

    @zmansuri 

    My variables were confined to one page, I don't know enough yet to remove everything and redo the variables as global. I ended up created a collection (using ClearCollect) populated by my SharePoint site and then am using formulas like CountRows(Filter(Collection, Approval_Status.Value="Rejected")) on labels to get the result I need. I didn't do it the way I wanted, but I don 't have a problem anymore.

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    glad you worked it out.

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 386 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 361

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 339 Super User 2025 Season 2

Last 30 days Overall leaderboard