Something we’ve noticed over time is that finding clear examples of Microsoft Power Apps formulas across the internet can be a bit challenging. So, we decided to put together this post to start building a helpful list of formulas we often use, regardless of your current skill level. We plan to keep this article updated regularly, so please check back often! We really hope you find it useful.
Microsoft Power Apps Best Practices
Here are a few best practices to keep in mind when working with Power Apps:
- Power Apps tends to create quite a few objects automatically when you add fields and forms. It’s really worth taking the time to rename these objects, especially if you’ll be adding any specific logic to them. Doing this upfront will make it much easier down the road to figure out what’s happening behind the scenes. For instance, “Datacard4.value” isn’t very descriptive or helpful to anyone looking at your app’s code.
- Spend some time early on planning out the screens you’ll need and identifying the elements you want to appear consistently across all of them. This often includes things like a navigation bar at the top or on the left, or perhaps a footer. Once you know what elements you want everywhere, you might be able to create reusable components, which can really help boost your app’s performance.
- If your company has established branding guidelines, take a look at those before you dive into building. These typically cover things like fonts, color palettes, and icons. If your company doesn’t have formal guidelines, decide on a color scheme and make sure the people who will actually use the app like it before you start applying it throughout the entire design.
- Have a clear understanding of your short-term and long-term expectations for data management and storage right from the start. Power Apps has limitations on how much data it can pull from different data sources. You need to explore these limits and factor them into your plan before connecting any data source to your app.
- Consider whether your Power App needs to be built in a separate development environment first. This decision usually depends on how many people are working on the app and how many Power Apps your company already has in use. If you’re the sole person managing the app, developing directly in production might be perfectly fine. However, if multiple team members are contributing to the app or your company already has several live Power Apps, it’s likely a good idea to build in a dedicated development environment initially.
Examples of Microsoft Power Apps Formulas
Filter a Power Apps Gallery Using an Or Statement for Multiple Fields
You can easily filter a Power Apps gallery based on criteria from several different fields simultaneously. This lets you create a personalized search experience where users can include or exclude information they’re looking for. Here’s how you can filter a Power Apps gallery using an ‘Or’ statement across multiple fields:
- First, add a text input control to your Power App and give it a clear name, like “Searchbox”.
- Make sure your data source is set up with the fields you need and connected to your Power App. Let’s imagine you have a data source called CompanyTasks with three fields: Title, Status, and AssignedTo.
- Add a gallery control to your Power App screen and connect it to your CompanyTasks data source.
- Select the “Items” property for your gallery. Initially, its formula might just be set to CompanyTasks.
- Now, change the formula to filter the gallery items based on the text entered in the “Searchbox” across all three fields. The formula would look like this: Filter(CompanyTasks, Or(Searchbox.Text in Title, Searchbox.Text in Status, Searchbox.Text in AssignedTo))
Keep in mind there are many ways to adapt this for searching. Always be aware of delegation limits. Also, think about whether users need exact matches, “starts with” matches, or searches that find the text anywhere in the field. It’s smart to clarify exactly how users expect the search to work so you can deliver the most effective results.
Filter(CompanyTasks, Or(Searchbox.Text in Title, Searchbox.Text in Status, Searchbox.Text in AssignedTo)
Clear a Textbox or Field in Power Apps
Need to quickly clear out the content of a text input or another field? Here’s how you do it:
- Double-check that the field you want to clear has been properly named. For our example, we’ll use the name “Searchbox”.
- Place an icon on your Power App screen. We recommend using the ‘Cancel’ icon and positioning it right next to the field you intend to clear for easy access.
- Select the “OnSelect” property for the icon.
- Add the formula Reset(Searchbox) to this icon’s OnSelect property.
Just remember that “Searchbox” in step 4 needs to be replaced with the actual name of your specific field from step 1
Add Line Breaks to Labels or Textboxes in Power Apps
If you need to include line breaks within the text displayed in a label or a text input field in Power Apps, you can use Char(13). You’ll add this within the “Text” property for a label or the “Default” property for a text input. Why might you use a text input for a large block of default text? Because text input controls offer different design and formatting options compared to labels. Choose the field type that best suits what you’re trying to achieve visually and functionally.
Here’s a simple formula example showing how to add a line break in Power Apps:
“Line 1” & Char(13) & “Line 2”
If you use Char(13) twice, you’ll get an extra blank line between your rows of text, like this:
“Line 1” & Char(13) & Char(13) & “Line 2”
Open SharePoint Online Files using Power Apps in a Different Browser Tab
It’s actually quite straightforward to configure your Power App to open SharePoint Online files in a new browser tab.
Here’s how you set this up:
- Make sure you have a document library already set up in SharePoint Online containing the files you want to open.
- Add a gallery control to the Power Apps screen where you want users to access files, and connect this gallery to your SharePoint document library.
- Find the “OnSelect” property for the “right arrow” icon (or whichever icon/control you want users to click to open the file) within your gallery template. Set its formula to Launch(ThisItem.’Link to item’).
Launch(ThisItem.’Link to item’)
Conditional Show and Hide Fields
You can create a single conditional logic statement and reuse it across any field you need to dynamically show or hide. Just make sure all your fields and objects are labeled clearly from the start.