Sunday, January 7, 2018

How to: Use variables in PowerApps.

Hi All, 
I am testing how could I perform the sort functionality    in MY CUSTOM APP which is readily available on SharePoint Online. 

PowerApps team already defines some variables specially for SharePoint integration. PowerApps has an amazing documentation about understanding variables.

Let’s dissect how the sorting functions for SharePoint App.


Open PowerApps Studio, click on New >> SharePoint > choose Phone Layout.




Choose a Phone layout as shown:





If you click on the sort icon, there is OnSelect property with formula UpdateContext({SortDescending1: !SortDescending1}) which already defines.



Navigate to File >> Variables. You can see a Boolean variable called SortDescending1



where this variable is used.



You can simulate in your own custom app.

Step1: Create an App

Create a new PowerApps studio by navigating to New >> choose Blank app and choose Phone Layout.



You create a sample excel sheet as our data source.  In the New connection >> Add static data to your app and locate your Excel sheet. 



Step2: Choose a data source.

You create a sample excel sheet as our data source.  In the New connection >> Add static data to your app and locate your Excel sheet

. 

Step3: From Insert tab, click on Gallery Control. Also add Sort Icon from the Icons control.



Step4: Click on Sort Icon

Use the formula in the formula bar as shown
UpdateContext({MySortOrder: !MySortOrder})




Step5: New Variable

Now, you can view a new variable in the Variable section of PowerApps Studio.



Step6: Gallery’s Items Property

You need to set this formula in the Item’s property as follows:
SortByColumns(Search(SpecialistAllocation,txtSearch.Text,"Title"),"Title", If(MySortOrder, SortOrder.Descending, SortOrder.Ascending))






Step7: Test

You can click on Preview and test the Sort functionality







I hope this post helped you!

1 comment:

changusa said...

Looks like it started with assending, how do I make it start with descending? Thanks, Ted

Low Code Reimagined with AI + Copilot Pitch Deck - Copy Copilot day (Virtual) - 2023

 Hi All,  I presneded a session at Pune UG on Low Code Reimagined with AI + Copilot Pitch Deck.  Video is at this address  https://www.youtu...