Power Apps Galleries and Forms
Earn 25 points (50 with Pro) in two steps
- ① Read through the lesson — each section gets a ✓ as you scroll through it.
- ② When every section has a ✓, tap Complete lesson.
0 of 8 read · keep scrolling
✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro
Mastering Power Apps: Galleries and Forms
Introduction: The Foundation of Data Interaction
If you have spent any time working within the Microsoft Power Platform, you have undoubtedly encountered Galleries and Forms. These two controls are the absolute bedrock of almost every canvas application built today. While a Power App might look like a collection of buttons, icons, and labels, the real value of the application lies in how it surfaces, organizes, and modifies data. Galleries allow users to view lists of information, while Forms provide the structure necessary to create, edit, and save that data back to your data source.
Understanding how to manipulate these controls effectively is what separates a basic, static application from a professional-grade tool that solves complex business problems. When you master Galleries, you master the art of data presentation; when you master Forms, you master the art of data integrity. In this lesson, we will peel back the layers of these controls, looking not just at how to drag and drop them onto a screen, but how to optimize their performance, handle complex data scenarios, and ensure that your users have a responsive and intuitive experience.
Not read yet
Part 1: The Power of Galleries
A Gallery is essentially a container for a repeating set of data. Think of it as a smart list. You provide a data source—such as a SharePoint list, a Dataverse table, or an Excel file—and the Gallery automatically generates a template row that repeats for every item in that source. However, a Gallery is far more than just a list of text; it is a highly customizable canvas that can hold images, icons, buttons, and even nested galleries.
Anatomy of a Gallery
When you insert a Gallery, you are presented with several layouts, such as "Vertical," "Horizontal," or "Blank." Regardless of the choice, the internal structure remains consistent. The Gallery control has an Items property, which dictates what data is displayed. Within the gallery, there is a "Template" area. Any control you place inside this template is replicated for every record returned by the Items property.
Callout: Gallery vs. Data Table Many beginners are tempted to use the "Data Table" control because it looks like a spreadsheet. However, the Data Table is limited in terms of styling and interactivity. Galleries are far superior because they allow you to place buttons, toggle switches, and complex formulas inside each row. Use Data Tables only for quick, read-only internal administrative views; use Galleries for everything else.
Practical Data Filtering and Sorting
One of the most common requirements in a business application is the ability to filter data. Instead of showing a user 5,000 records, you should present them with a manageable subset. The Items property of your gallery is where you define this logic.
To filter a list based on a text input, you would use the Filter function combined with the Search function. Consider this example where you have a list of employees:
Filter(
Employees,
Department = Dropdown_Dept.Selected.Value,
StartsWith(FullName, txt_Search.Text)
)
In this code, the Filter function scans the Employees data source. It first checks if the Department column matches the selection from a dropdown control. Then, it uses the StartsWith function to ensure that the FullName begins with whatever the user has typed into the search box. This keeps the gallery responsive and relevant to the user's current task.
Improving Gallery Performance
Performance is a significant concern when dealing with large datasets. If your Items property is too complex, the application will feel sluggish. Here are a few best practices to keep your galleries snappy:
- Delegation: Always ensure your
Itemsformula is "delegable." This means the filtering is performed on the server side (by SharePoint or Dataverse) rather than on the user's device. If you use functions that are not delegable, likeSearchon certain data sources, Power Apps will only retrieve the first 500 or 2,000 records, which can lead to data loss in your view. - Limit Columns: If you are using a large Dataverse table, only fetch the columns you actually need. While Power Apps often handles this automatically, being mindful of your data retrieval scope is a good habit.
- Virtualization: Galleries are automatically virtualized, meaning they only render the items visible on the screen. Do not try to force a gallery to render 1,000 items at once; instead, use pagination or search filters to keep the view focused.
Not read yet
Part 2: Mastering Forms for Data Input
While Galleries are for viewing, Forms are for interacting. An "Edit Form" or "Display Form" is a container that binds directly to a record in your data source. When you connect a form to a SharePoint list or Dataverse table, Power Apps automatically generates the input fields based on the schema of that list.
Understanding Form Modes
A Form control has a property called Mode. This property is critical to how the form behaves:
- FormMode.Edit: Used to modify an existing record. You must provide the form with a specific record via the
Itemproperty (e.g.,Gallery1.Selected). - FormMode.New: Used to create a brand-new record. The
Itemproperty should typically be set toDefaults(YourDataSource). - FormMode.View: Used to display a record without allowing the user to make changes.
Note: Always use the
SubmitFormfunction to save data from a form. Some beginners try to patch fields individually to a data source, but usingSubmitFormis the standard way to handle form validation, error messages, and data submission in one clean step.
Customizing Form Cards
Every field in a form is wrapped in a "Data Card." These cards are essentially containers that hold the label, the input control (like a text box or dropdown), and an error message control. You can unlock these cards to change their appearance, add conditional formatting, or move them around.
If you need to change the visibility of a field based on another field, you can select the Data Card and set its Visible property:
// Set the Visible property of a "Comments" card to true only if "Status" is "Rejected"
DataCard_Comments.Visible = Dropdown_Status.Selected.Value = "Rejected"
This level of dynamic control is what makes Power Apps so powerful. You aren't just creating a static form; you are creating a logical interface that adapts to the user's input in real-time.
Handling Data Submission Errors
When using SubmitForm, it is important to provide feedback to the user. You should use the OnSuccess and OnFailure properties of the form to trigger notifications.
- OnSuccess: Use
Notify("Data saved successfully!", NotificationType.Success)to reassure the user that their work is safe. - OnFailure: Use
Notify("There was an error saving your data.", NotificationType.Error)to alert them if something goes wrong, such as a network timeout or a validation issue.
Not read yet
Part 3: Advanced Techniques and Integration
Once you have mastered the basics of Galleries and Forms, you can start combining them to create sophisticated workflows. A common pattern is the "Master-Detail" view, where a Gallery on the left shows a list of items, and a Form on the right shows the details of the item selected in the gallery.
The Master-Detail Pattern
To implement this, set the Item property of your Form to Gallery1.Selected. When the user clicks an item in the gallery, the form automatically updates to show the information for that specific record.
Tip: If you want to allow the user to switch between "Edit" and "View" modes for the same record, create a variable (e.g.,
varFormMode) and toggle it using a button. Set theModeproperty of your form to this variable. This prevents the need for two separate screens.
Working with Complex Data Types
Sometimes, your data source will contain complex types like Choice columns, Lookups, or Attachments.
- Choices: Power Apps handles these well with the
ComboBoxcontrol. Ensure theItemsproperty of the combo box is set toChoices(DataSourceName.ColumnName). - Lookups: If you are linking two tables, the
DefaultSelectedItemsproperty of the combo box is where you define the link. Always use theLookUpfunction to ensure the correct record is identified. - Attachments: The "Attachment" control in Power Apps is a specialized control that only works inside a Form. Do not try to move it outside the form or copy-paste it into a gallery; it requires the context of the parent form to manage the file upload process correctly.
Not read yet
Part 4: Common Pitfalls and How to Avoid Them
Even experienced developers can fall into traps when working with these controls. Here are the most frequent mistakes I see in production environments.
1. Hard-Coding Values
Avoid hard-coding values like "Pending" or "Approved" directly into formulas. If the business changes these terms later, you will have to hunt through every formula in your app to update them. Instead, use a "Configuration" list or a local collection to store these values, and reference that variable or list.
2. Ignoring Delegation Warnings
Power Apps will show a yellow warning triangle if your formula is not delegable. Never ignore these. If your app works perfectly with 50 items but breaks when you hit 501 items, it is because of a delegation error. Always check your formulas against the documentation for your specific data source (SharePoint, SQL, or Dataverse).
3. Over-Complicating the Gallery Template
Keep the Gallery template as light as possible. If you have 50 items in a gallery, and each item has 10 complex nested controls, the app will consume a massive amount of memory. Use icons instead of images where possible, and avoid complex calculations inside the gallery template controls.
4. Forgetting to Reset Forms
When a user finishes editing an item, they might close the form. If they open it again, the old data might still be there. Always use the ResetForm function when navigating away or when a user clicks "Cancel."
// Example of a Cancel button formula
ResetForm(Form_Main);
Navigate(Screen_Dashboard);
Not read yet
Part 5: Comparison of Controls
To help you decide which control to use for specific scenarios, refer to the table below.
| Feature | Gallery | Form | Data Table |
|---|---|---|---|
| Primary Use | Browsing/Selecting | Editing/Creating | Read-only lists |
| Customization | Very High | Medium | Low |
| Data Binding | Items (Collection) |
Item (Single record) |
Items (Collection) |
| User Input | Possible (via controls) | Native (Form controls) | None |
| Best For | Dashboards, Search results | Data entry, Profiles | Quick reporting |
Part 6: Best Practices for Production Apps
When building for an organization, consistency is key. Your users should have a predictable experience regardless of which screen they are on.
- Consistent Naming: Use a naming convention for your controls. For example,
gal_Employees,frm_EmployeeDetails,txt_Search, andbtn_Submit. This makes debugging much easier when you are looking at a list of hundreds of controls. - Validation: Use the
Visibleproperty of icons to show validation warnings. For example, if a mandatory field is empty, show a red exclamation icon next to the field. Use theValidproperty of the form to enable or disable the "Submit" button. - The "Loading" State: For complex forms, use a variable to show a loading spinner while the
SubmitFormfunction is running. This prevents users from clicking the "Submit" button multiple times, which can create duplicate records.
Callout: The Power of 'Patch' While
SubmitFormis the standard for forms, thePatchfunction is the standard for "on-the-fly" updates. If you want to update a single status field without showing a full form, usePatch(DataSource, Record, {Status: "Complete"}). This is faster and cleaner for simple updates.
Not read yet
Part 7: Step-by-Step: Creating a Basic Edit Flow
To solidify these concepts, let’s walk through the process of creating a standard Edit flow.
Step 1: Setup the Gallery
- Insert a Gallery control onto your screen.
- Connect it to your data source (e.g.,
Projects). - In the Gallery, add labels for
Title,Status, andDueDate.
Step 2: Setup the Form
- Add an "Edit Form" control to the same screen.
- Connect it to the same
Projectsdata source. - Set the
Itemproperty of the form toGallery1.Selected.
Step 3: Link the Selection
- When a user taps an item in the gallery, the
OnSelectproperty is usually set toSelect(Parent). This is fine. - Ensure the form fields are visible. If they are hidden, select the form and use the "Edit Fields" pane to add the columns you need.
Step 4: Add the Save Button
- Add a button outside the form.
- Set the
OnSelectproperty toSubmitForm(Form1). - Set the
DisplayModeof the button toIf(Form1.Valid, DisplayMode.Edit, DisplayMode.Disabled). This ensures the user cannot save if the form has errors.
Step 5: Feedback Loop
- Set the
OnSuccessproperty of the form to:Notify("Saved!", NotificationType.Success); Navigate(Screen_Dashboard). - Set the
OnFailureproperty to:Notify("Error!", NotificationType.Error).
This simple flow covers 90% of the data entry requirements in most business applications. By following this pattern, you ensure that your app is reliable, user-friendly, and easy to maintain.
Not read yet
Summary and Key Takeaways
We have covered a significant amount of ground regarding the two most critical components of Power Apps. By understanding how to manipulate Galleries for display and Forms for input, you have the building blocks to create nearly any business application.
Key Takeaways:
- Galleries are for Lists: Always prefer Galleries over Data Tables for their superior customization and control. Use them to display data, facilitate searching, and allow for item selection.
- Forms are for Integrity: Use Forms to ensure that data entry follows the rules of your data source. Leverage
SubmitFormto handle the heavy lifting of data validation and submission. - Master the
ItemProperty: The magic of a Master-Detail view is simply binding the Form’sItemproperty to the Gallery’sSelectedproperty. This creates a powerful, reactive interface. - Prioritize Delegation: Always be aware of delegation warnings. If your app needs to work with large datasets, your formulas must be delegable to keep the app performing well and the data accurate.
- Use Feedback Loops: Never leave the user guessing. Always use
Notifyand clear UI indicators (like spinners or validation icons) to communicate the state of the application. - Keep it Simple: Avoid over-engineering your gallery templates or form layouts. A clean, simple interface is almost always easier to maintain and faster for the user to navigate.
- Consistency Matters: Adopt a naming convention for your controls early. When your app grows to include dozens of screens, you will be grateful for a structured approach to naming your galleries, forms, and data cards.
By applying these principles, you will move from simply "making things work" to building professional-grade applications that are robust, scalable, and intuitive for your end users. Remember that Power Apps is an iterative process; start with the basic functionality, test it, and then refine your UI and logic as you learn more about your users' needs.
Not read yet
Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.
- Introduction to Microsoft Power Platform
- Introduction to Microsoft Power Platform Quiz5q
- Value of Power Apps for Building Applications
- Value of Power Apps for Building Applications Quiz5q
- Value of Power Automate for Process Automation
- Value of Power Automate for Process Automation Quiz5q
- Value of Power Pages for Building Websites
- Value of Power Pages for Building Websites Quiz5q
- Value of Connectors for Integration
- Value of Connectors for Integration Quiz5q
- Value of Microsoft Dataverse for Business Data
- Value of Microsoft Dataverse for Business Data Quiz5q
- Dataverse vs Traditional Databases
- Dataverse vs Traditional Databases Quiz5q
- Tables Columns and Relationships in Dataverse
- Tables Columns and Relationships in Dataverse Quiz5q
- Business Logic Options in Dataverse
- Business Logic Options in Dataverse Quiz5q
- Creating Tables and Columns Through Conversations
- Creating Tables and Columns Through Conversations Quiz5q
- Importing and Exporting Data Options
- Importing and Exporting Data Options Quiz5q
- Dataverse Business Rules
- Dataverse Business Rules Quiz5q
- Dataverse Calculated and Rollup Columns
- Dataverse Calculated and Rollup Columns Quiz5q
- Dataverse Security Roles
- Dataverse Security Roles Quiz5q
- Dataverse Teams Integration
- Dataverse Teams Integration Quiz5q
- Dataverse File and Image Columns
- Dataverse File and Image Columns Quiz5q
- Connecting to Data Sources with Connectors
- Connecting to Data Sources with Connectors Quiz5q
- Common Controls in Canvas Apps
- Common Controls in Canvas Apps Quiz5q
- Building Responsive Pages with Containers
- Building Responsive Pages with Containers Quiz5q
- Capabilities of Copilot Controls
- Capabilities of Copilot Controls Quiz5q
- Sharing a Canvas App
- Sharing a Canvas App Quiz5q
- Cloud Flows and Desktop Flows
- Cloud Flows and Desktop Flows Quiz5q
- Cloud Flow Templates
- Cloud Flow Templates Quiz5q
- Connector Triggers and Actions
- Connector Triggers and Actions Quiz5q
- Power Automate Use Cases
- Power Automate Use Cases Quiz5q
- Power Automate Apps and Portals
- Power Automate Apps and Portals Quiz5q
- Desktop Flow Actions
- Desktop Flow Actions Quiz5q
- Process Mining Overview
- Process Mining Overview Quiz5q
- Loops and Branching in Cloud Flows
- Loops and Branching in Cloud Flows Quiz5q
- Creating Cloud Flows with Triggers
- Creating Cloud Flows with Triggers Quiz5q
- Creating Flows Through Conversations
- Creating Flows Through Conversations Quiz5q
- Running and Monitoring Cloud Flows
- Running and Monitoring Cloud Flows Quiz5q
- Testing a Cloud Flow
- Testing a Cloud Flow Quiz5q
- Sharing a Cloud Flow
- Sharing a Cloud Flow Quiz5q
- Creating Sites Using Copilot
- Creating Sites Using Copilot Quiz5q
- Design Studio Workspaces
- Design Studio Workspaces Quiz5q
- Creating and Modifying Pages
- Creating and Modifying Pages Quiz5q
- Configuring Power Pages Components
- Configuring Power Pages Components Quiz5q
- Modifying a Power Pages Theme
- Modifying a Power Pages Theme Quiz5q
- Power Pages Authentication Options
- Power Pages Authentication Options Quiz5q
- Power Pages Web Roles
- Power Pages Web Roles Quiz5q
- Power Pages Table Permissions
- Power Pages Table Permissions Quiz5q
- Power Pages List and Form Components
- Power Pages List and Form Components Quiz5q
- Power Pages Publishing and Deployment
- Power Pages Publishing and Deployment Quiz5q
Spend your points to unlock exam-style practice questions
Spend points to unlock PL-900 exam-style practice questions.
Practice for PL-900