Download a File from a Canvas Power App using a button | Power Platform

Let’s say you give a simple button to download a standard PDF file to the user. It could be a pre-defined file which already exists somewhere and your App readily has the URL to the file. You only need to provision a button to the user to download and they can simply click it and download the file to the device.

Let’s see how!

Scenario

Let’s say salespeople in your organization have access to Accounts and each Account has an exclusive Document to that Account, say, some type of Agreement/Whitepaper.

For simplicity, I’m storing the URL of the Document in a field. However, you can have a different (and better) ways to represent this. Finally, all you need is a URL to the file to be downloaded.

Download button

Here’s how I’m implementing it. To keep it simple, I’m only reading from the field on my Accounts, called as Agreement Doc URL.

Consideration: To keep this post simple, I didn’t go into the SharePoint Access settings, etc. Make sure the file is hosted over the internet and doesn’t have to go through a lot of settings to be accessible.

  1. Here’s my Gallery that shows all the Accounts.

  2. When I make a selected to any of the records, it’ll open the Form and pre-populate the form with the selected record. However, your application could be anything.
  3. I’ll place a button on click of which, I’ll write the Function to download a file.

  4. And the function used it Download()

    In my example, I’m choosing to download the file which is supposedly coming from my AccountView (which is a Gallery). Selected method is pointing to the row from my CDS Data Source which I selected in the Gallery and navigated to the Formevery of my Account records have their own respective URLs and Agreement Doc URL is the name of the field in which the URL to the document resides.

    Here’s Microsoft Document on this function – https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-download/?WT.mc_id=DX-MVP-5003911

Working

Hope this helps! Here are some more Canvas Power Apps related posted you might want to check out –

  1. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  2. Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
  3. Accept HTTP Requests in a Flow and send Response back | Power Automate
  4. Terminate a Flow with Failed/Cancelled status | Power Automate
  5. Adaptive Cards for Teams to collect data from users using Power Automate | SharePoint Lists
  6. ChildFlowUnsupportedForInvokerConnections error while using Child Flows [SOLVED] | Power Automate
  7. BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
  8. Pause a Flow using Delay and Delay Until | Power Automate
  9. Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
  10. Text Functions in a Flow | Power Automate
  11. Loop through array of objects in a Flow & Create records in CDS | Power Automate
  12. Get Count of records retrieved in CDS connector in a Flow | Power Automate

Thanks.

AddColumns() function to dynamically add columns to a Data table in Canvas Power App | SharePoint List

At times, you want to do a quick calculation but the Data Source doesn’t have that column present.

Example, you’re populating some data from a SharePoint List which is a Scoreboard. But it doesn’t tell the difference between the current Score and Top Score.

So, to find how many points does the Score trails by the Top Score. To do that, we’ll dynamically add a Column to our Data Table in a Canvas Power App by using AddColumn() function.

SharePoint List & Canvas App

First part is the list itself which you already saw above, I have the below Canvas App –

  1. The only thing I have in this Canvas App is a Data table which I named as ScoreBoard

    Which will look like this

  2. I’m setting the Data Source of this Data Table to be DynamicList and not the actual SharePoint List. Because, in order to create a dynamic column, I should be using Collections in this demo and I can’t use the SharePoint List as Data Source directly.

  3. And to write my function, I’ll also add a Button so that on click of which, I can populate my internal Data Source in this case which is Collection called as DynamicList to be populated with data. You can use any other way as suitable.

AddColumn() function

  1. Since I want to generate my dynamic column, I’ll first use ClearCollect() method to add the SharePoint List with the dynamic column to my Collection which I’ll call as DynamicList.
    All this OnSelect of the Button which I added.

  2. The formula goes as below
    ClearCollect(<NameOfCollection>, AddColumns(<ActualDataSource>,”ColumnName”,<Expression>))

    In the above formula,
    ClearCollect(DynamicList) is being created to create a Collection called DynamicList and Clear if there’s any pre-existing data in it before populating fresh data.
    AddColumns(Scoreboard,”Trial By”, ‘Top Score’ – Score) – Scoreboard is the actual SharePoint List I’m using which doesn’t have the column, Trial By is the dynamic column I’m creating. And my expression is Subtract Score from Top Score so that I get the difference.

  3. Make sure you select the columns. Perhaps once you run in in your browser, and try to click the button, the column will be available for your selection in the below Edit Fields section. [I had to do a little back and forth, perhaps you might have a smarter way 😊]




Run

Now, when I run the app, and click on Load Scoreboard button, I see the below data populated with by dynamic column Trail By.


Hope this was useful.

Here are some more Power Automate / Flow posts you might want to check

  1. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  2. Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
  3. Accept HTTP Requests in a Flow and send Response back | Power Automate
  4. Terminate a Flow with Failed/Cancelled status | Power Automate
  5. Adaptive Cards for Teams to collect data from users using Power Automate | SharePoint Lists
  6. ChildFlowUnsupportedForInvokerConnections error while using Child Flows [SOLVED] | Power Automate
  7. BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
  8. Pause a Flow using Delay and Delay Until | Power Automate
  9. Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
  10. Text Functions in a Flow | Power Automate
  11. Loop through array of objects in a Flow & Create records in CDS | Power Automate
  12. Get Count of records retrieved in CDS connector in a Flow | Power Automate

Thank you!

Implement real-time search in Gallery of CDS records in a Canvas Power App | Power Platform

One of the most common asks is to be able to search CDS records in a Gallery control in real-time using a Text-box.

Search Box & Gallery connected to CDS

Let’s design a simple gallery that is populated with CDS records from Account entity.

  1. Take a Text Input control (Textbox) and make it look like a Search Box.

    In order to have the Search watermark, write the text to appear as water-mark, enter it in Hint text property of the Text input


  2. Take a Gallery control and select Data Source as Accounts from CDS.


    The way the above shown Gallery control is populated is by selecting a CDS Data Source which is as below –

Filter records

Finally, there’s a 1-line formula that will do the trick for you

  1. In the Items property of the CDS Gallery, I have to filter the records based on the Text of the Text Input on my form.


    Marked by green arrow Filter() function is the one which handles filtering of the data set based on the parameters demanded by the method. Here’s Microsoft Docs on the same – https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-filter-lookup

    Underlined by red Accounts is the CDS data source which I want to filter on.

    StartsWith() is a method which is used to compare the start of the string in question. In this case, the text I enter in the SearchField textbox.

    1. ‘Account Name’ is the field in the Accounts dataset to be considered on which the search parameter is dependent.
    2. Underlined by purple SearchField.Text in which SearchField is the textbox which is used to query the Name of the Account and .Text is Text value of the string which will be considered.

    So at all times, whenever there’s a change in the Textbox value, the Items of the Gallery control are supposed to be updated with the filtered records.

Working

Now, when you use the App, here’s what it will behave like. As you type, the records will filter with a certain delay (depending on how large your dataset is)

Hope this was useful!!

Here are some more Canvas Power Apps posts you might want to check –

  1. https://d365demystified.com/2020/08/31/log-canvas-power-app-telemetry-data-in-azure-application-insights-power-apps/
  2. https://d365demystified.com/2020/08/25/call-http-request-from-a-canvas-power-app-using-flow-and-get-back-response-power-automate/
  3. https://d365demystified.com/2020/08/16/send-a-power-app-push-notification-using-flow-to-open-a-record-in-canvas-app-power-automate/
  4. https://d365demystified.com/2020/08/07/recover-deleted-d365-powerapp-environment-using-powershell/
  5. https://d365demystified.com/2020/08/07/recover-deleted-d365-powerapp-environment-using-powershell/

Thanks!

Log Canvas Power App telemetry data in Azure Application Insights | Power Apps

Here’s how you can register your Canvas Power App in your Azure’s Application Insights and log telemetry data into Azure.

Some basic info about what all you can see in Application Insights is –

  1. Count of Users who used the app
  2. Events logged, Sessions logged
  3. Device info
  4. Region info

It’s quite simple to set it up! Let’s take a look –

Registering in Application Insights in Azure

First, make sure you do have an Azure Subscription. Let’s look at how you can register an Application Insight record.

  1. Look for Application Insights in Azure in the search bar

  2. Then, among other records, you can register a new one which will identify with your Canvas Power App

  3. Review all that you entered and move ahead

  4. It’ll be deployed pretty quickly within a few minutes unlike some heavy Azure resources

  5. Upon completion, you can navigate to the resource and see the details

    Zoomed In


Add Instrumentation Key to Canvas Power App

Next step is to add the Instrumentation Key to the Canvas Power App

  1. Look for the App itself in the Navigation tree

  2. Once you select that, you can then look at it’s Properties on the right hand side. In Instrumentation Key, paste the Instrumentation Key you copied when you created the App in the Azure.

  3. And to go with that, let’s say my Canvas Power App has some basic structure like below

Using Application Insights

As the users use the Canvas App, the following information is logged –

  1. Navigate to the Usage section in the Application Insights you registered and if you scroll down on the main pane, you can see w

  2. And then scroll down to reveal more Insight data


  3. Or, if you see Events, you can see info like this –

    I’m not completely sure why my users showed high when I tried with only 2 users. But perhaps, once I dive more deeper into using Application Insights and how each of the metrics are read, I’ll come back to update this post. 😊

And likewise, if you know how to read the Application Insights, you can customize this to give you what you need to see.

Here is some Microsoft Documentation on Application Insights to help you out –

  1. https://docs.microsoft.com/en-us/azure/azure-monitor/app/usage-segmentation

Hope this was useful. Here are more Azure/Canvas Power App related posts you might want to check –

  1. Call Azure Function from Dynamics 365 CRM using Webhooks
  2. Use Azure App Passwords for MFA enabled D365 authentication from Console App
  3. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  4. Launch URL on a Data Table Text column selection in a Canvas PowerApp | SharePoint Lists
  5. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  6. Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
  7. Aggregate functions in a Canvas Power App | Using on SharePoint Lists
  8. Count of total CDS records returned in a Canvas Power App connection [Quick Tip]
  9. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  10. Implement character length validation in a Canvas Power App | Power Platform

Thank you!

Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate

Now, there are several questions about how can we make HTTP requests from a Canvas Power App. Well, as of today, only HTTP with Azure AD exists in native Canvas Power App Connectors, so in order to call HTTP requests only to external resources, you’ll need to go via a Flow and get response back.

Scenario

Call a Flow from within a Canvas Power App and capture the response back in the Canvas Power App.

In my example to keep things easy, I’m using a sample HTTP request provided by https://openweathermap.org/ (OpenWeatherMap) [I know there are native Weather connectors, but I’m just using as an example]

Flow

Here’s how Flow looks –

  1. Let’s say I create an Automated Flow which is triggered from a Power App. Just select that, there’s nothing to add to it.


  2. Next Step, I’ll make an HTTP request to a Service (In my example, I want to retrieve Humidity. You would of course have your use case)
    I’ve used the same example in one of my posts where I talked about making HTTP requests using Flow. Check this post – Make HTTP request from Flow in Power Automate


  3. To breakdown my received HTTP response into distinct pieces of info, I’ll parse it.

  4. Final step would be to send back the parsed info to the Power App itself so that I can use the info internally in the Canvas Power App from which this Flow was called.

  5. Now, I’m choosing to send back the Humidity value. So, I’ll choose a type of Output to be sent my response into

  6. And since I already parsed the response in the step above, it’s easy to select what piece of info I want to send back to my Canvas Power App.
    I’ve created a variable called as humidityValue and in that I’m passing humidity from the parsed JSON step.

  7. That’s it. My Flow overall looks like this

Canvas Power App

In my Canvas Power App, I only have a button which will populate the data into a label –

  1. Let’s say, I have a button called as Get Humidity. And below it, is a Label having “Humidity is” already written

  2. Now, the next step is to add the Flow in the Canvas Power App. Navigate to Action in the menu bar in Canvas Power App Studio and look for Power Automate

  3. On clicking it, you’ll be able to select the Flow you want to add in the Canvas Power App

  4. Once you select that, it’ll appear on the OnSelect formula bar of the button. Ideally, this should be added to whatever event you want the Flow to Run from (In my case, click of Get Humidity button)
    It’ll populate with a default formula like below. But we need some modification for it to be populated to the Label.

  5. Now, you can write the below formula to add the value retrieved from the variable which you created dynamically called as ‘humidity‘ and upon adding dot to the Run(), you’ll be able to select the variable you passed to the Canvas App from Flow.

  6. So, the completed Formula looks like this.
    Here, I’m using Set() function to set a dynamically declared variable in called as humidity and populate it with the value of humidityValue which we’ll get when we run Flow and the Flow will make an HTTP call to get that value.
    In case you also need to understand how variables work, you can refer this post of mine – Variables in Canvas Power Apps | Global and Context

  7. Now, we need to set it to the Label. So, we’ll write a formula on the Label’s Text event. So that, the Label is displaying Humidity is <valueOfHumidity> variable

  8. And you’re set. Hope this explanation was easy. Now, let’s Run the App and click Get Humidity button

Working

When I click a button, I’ll get the value into the Label field which I created.

When I click the button, it’ll be greyed out for a moment while the Canvas Power App calls the Flow and the Flow runs the HTTP request and sends back response to Canvas Power App.

Finally, once the variable is set, the Label control will display the value as below which came via HTTP using Flow

You can also see the results going in the Flow Run as well

Hope this was useful. Here are some more Canvas Power App & Power Automate posts you might want to look at –

  1. Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
  2. Accept HTTP Requests in a Flow and send Response back | Power Automate
  3. Launch URL on a Data Table Text column selection in a Canvas PowerApp | SharePoint Lists
  4. Terminate a Flow with Failed/Cancelled status | Power Automate
  5. Aggregate functions in a Canvas Power App | Using on SharePoint Lists
  6. Logged In User details in a Canvas Power App
  7. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  8. Implement character length validation in a Canvas Power App | Power Platform
  9. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  10. Pause a Flow using Delay and Delay Until | Power Automate
  11. BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
  12. Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
  13. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  14. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  15. Using Parse JSON to read individual List Records in Flow|Power Automate

Thank you!

Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate

Let’s say most of your users are using custom Canvas Power Apps to follow their business tasks and rely on Canvas Apps for their actions inside Dynamics 365.

There could be scenarios where you want to notify them conditionally of important items that need their attention.

Scenario

Let’s say you have a few users whom you want to tell them that an Opportunity was Won. It could be a team or a single User.

Here’s what my scenario is – A PowerApp Notification is sent to designated User(s) using Flow. When an Opportunity is Won

A Power App Notification is received

And when user clicks he Notification, Canvas Power will open and show that record.

But of course, your implementation/applications for this can be limitless!! This is just my example!

Flow

Here’s what the Flow looks like –

  1. I’m triggering the Flow on Update of the Opportunity. You can use Trigger Conditions to make sure your Flow is triggered only on the update of the Opportunity Win

  2. [Optional, according to my scenario] I want to send this to the Owner of the Opportutnity for now. Of course, it makes sense to send it to others. But let’s keep it simple for now. 🙂
    So, I’m capturing Email address here to be used further down



  3. [Optional, according to my scenario] Further, I’m only checking if the Status was Won. Status Reason = 3 meaning Opportunity was Won


  4. Next, once your condition is satisfied, you can search for this Connector and Action in your Steps in the Flow.


  5. For now, you only have this one Action which you’ll need.


  6. This is how it looks –
    Recipient Item – 1 holds the Email address of the User to whom the notification will be sent to. More can be added by using the + Add new item button.
    Message holds what should be displayed when the notification is received to the end user.
    Open App – Yes/No. Boolean to set if the Power App is supposed to be Opened upon selecting the Notification or not.
    Parameters – You can pass parameters to the Canvas App and use it inside Canvas App. Example: To open the record directly if the App is designed in that way.



  7. First thing you need to do is to create a specific connection for this so that you can use it to open the specific App in Power App.


  8. You can give your Connection a name and then the ID of the App must be entered. Once done, click create.

  9. In case you’re wondering where you’ll get the App ID. You can find the Canvas App ID in the Details section of your Canvas Power App, you’ll only need that to be copied


  10. And you can enter the below options –
    In my example, I’m sending an alert to the email I captured in #2 above.. In your case, you can set this dynamically and add more as well by clicking on “+ Add new item

    In Message, I’ll enter what the notification should read.
    Open App is set to Yes. Means if I click the notification, it’ll open the Canvas Power App whose ID I used above to create the Connection.

    Parameters, this is optional. If you want to open the specific record, you can pass the GUID like this and in the next section, we’ll see how we can open the record using that.

Canvas Power App

In the previous step, remember we sent the Guid as parameter to the Canvas Power App, here’s what you can do to read the record and use it to open the specific record.
Here’s how you can read Parameters passed to the Canvas Power App.
Param(“<ParameterName>”)

I’m using it to Lookup the Opportunity that I passed from the Notification to the Canvas Power App.

In my application, I’m using Lookup to fetch the record and set it to the Item property of the Edit Form control


Some references to use if you’re looking to Capture Parameters and Lookup/Filter data based on your GUID is that’s your implementation.

  1. Pass Parameters to Canvas Power App – https://sachinbansal.blog/2018/06/17/powerapps-canvas-app-how-to-pass-parameter-in-app-url-display-data-based-on-parameter-passed/
  2. Lookup/Filter Records – http://linnzawwin.blogspot.com/2019/12/power-apps-using-common-data-services.html

Working

Let’s say an Opportunity was Won in Dynamics 365.

And the user will receive a notification like this.


Clicking on which, they’ll be taken to the Canvas Power App record which I set in my Canvas Power App.

Hope this was helpful!

Here are some more Canvas Power App posts you might want to look at –

  1. Launch URL on a Data Table Text column selection in a Canvas PowerApp | SharePoint Lists
  2. Aggregate functions in a Canvas Power App | Using on SharePoint Lists
  3. Count of total CDS records returned in a Canvas Power App connection [Quick Tip]
  4. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  5. Restore older version of a Canvas Power App | Power Platform
  6. Logged In User details in a Canvas Power App
  7. Implement character length validation in a Canvas Power App | Power Platform
  8. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  9. Number Formatting in a Flow | Power Automate
  10. Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
  11. Accept HTTP Requests in a Flow and send Response back | Power Automate
  12. Pause a Flow using Delay and Delay Until | Power Automate

Thank you!

Recover deleted D365 PowerApp environment using PowerShell

To get the most important things out of the way, this can be done only within the first 7 Days.

Deleted Environment

At times, you want to delete an environment you don’t need. But you feel you do need it back. Deleting an environment from the Power Platform Admin Center will Soft Delete it and you can get it back within the first 7 days only.

Here’s some info by Microsoft on that: https://docs.microsoft.com/en-us/power-platform/admin/backup-restore-environments#how-long-are-my-manualon-demand-backups-and-system-backups-retained

Here’s what we can do within the first 7 days to get it back using PowerShell!

Get PowerShell Support for PowerApps

Before we are able to Run PowerShell directly to recover, you’ll need to get the support for PowerApps in your PowerShell first.

Refer this full Microsoft Documentation for full details: https://docs.microsoft.com/en-us/power-platform/admin/powerapps-powershell#power-apps-cmdlets-for-administrators-preview

  1. Open PowerShell and remember to Run it as as Administrator.



  2. Here’s how you can install the capabilities

    And then

    Here are the 2 commands which I used in the screenshots above in PowerShell. Below is the screenshot I took from Microsoft Docs so that you can visualize how the commands look
  • Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
  • Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber

    or if you don’t have Admin Access, below code can be used in PowerShell
  • Save-Module -Name Microsoft.PowerApps.Administration.PowerShell -Path
  • Import-Module -Name Microsoft.PowerApps.Administration.PowerShell
  • Save-Module -Name Microsoft.PowerApps.PowerShell -Path
  • Import-Module -Name Microsoft.PowerApps.PowerShell


4. Now, let’s say you are all set to execute your recovery process.

Recovery of Environment

Assuming you have completed the above steps, you can now proceed towards recovering the environment.

  1. Now, in PowerShell, run the below command “Get-AdminPowerAppSoftDeletedEnvironment

  2. You’ll be directed to a Login screen. Enter environment credentials there.


  3. You’ll get the Deleted environments’s details as below. In my case, only 1 Deleted environment was retrieved

    Note the first line i.e. EnvironmentName. Copy that GUID

  4. Next, run the below command after you copied the GUID –
    Recover-AdminPowerAppEnvironment -EnvironmentName 35545668-80c2-4d88-811d-b698bb1bcf59 -WaitUntilFinished $true

  5. Once completed, you won’t see any message but the cursor will be on the new line ready. And some details about the success of the operation.

  6. And in the Admin Center, the environment will be recovered.


    Hope this helps!!


    Here are some more Power Platform related posts you might want to check –
    1. Create new Sandbox and copy Production over to it in PowerPlatform Admin Center
    2. New ‘Capacity’ analytics on PowerPlatform Admin Center
    3. D365 Admin Center: Instance Picker Link

Thank you!


Launch URL on a Data Table Text column selection in a Canvas PowerApp | SharePoint Lists

Let’s say you are using SharePoint Lists to populate your Data Table in a Canvas Power App. And you have a Text column which could be typically name of the Website and another column could be a URL.

Now, you want to be able to click the Name of the Website and the selection should take you to the Website itself.

Scenario

Now, below is the Blog List in SharePoint you are populating your Data Table in a Canvas App with.

Now, I’ll use the above list to populate the Data Table to only show the Title in the Data Table and make the names clickable so that the URL of these Website names should be navigated to when you click them

Data Table column

  1. Firstly, the Names of the Blogs will appear in Plain Text because in SharePoint, this field is of Type plain text.


  2. In order to convert them to hyperlink, select the column as shown below


    And then, on the right hand side in Table Column Properties, turn on the Is hyperlink flag to On

  3. Now, the names will be clickable

Now, these Titles should be clickable and navigate to the URL which is mentioned for each of these Website Names.

OnSelect property and Launch Function

  1. Every Data Table column has an OnSelect property which you can set.

  2. Now, you can use the Launch() function to launch a URL which in this case will launch/open the data from the URL column of the Data Table (which we have not displayed anywhere in the Data Table)


    Now, here’s what the above Formula is set as
    Launch() will accept Text values. The “BlogList Data Table” is the name of the Data Table we are using i.e. the SharePoint List.
    .Selected will consider the Row we will click/select.
    And URL is the name of the column where the URL resides.
    Hence, it’ll Launch the URL we specified again each website name.

Working

When you open the App, and click on the name of the Site


Hope this was useful!!

Here are some more Canvas Power Apps posts you might want to check out

  1. Aggregate functions in a Canvas Power App | Using on SharePoint Lists
  2. Count of total CDS records returned in a Canvas Power App connection [Quick Tip]
  3. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  4. Restore older version of a Canvas Power App | Power Platform
  5. Implement character length validation in a Canvas Power App | Power Platform
  6. Logged In User details in a Canvas Power App
  7. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  8. Variables in Canvas Power Apps | Global and Context
  9. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  10. Adding a Canvas PowerApp to Teams

Thank you!


Aggregate functions in a Canvas Power App | Using on SharePoint Lists

Aggregate functions have one of the most common applications while building your Canvas Power App.

In this simple example, we’ll try to make common Aggregate Functions like Max, Min, Sum & Average work.

There are 2 more advanced Aggregate Functions, StdevP for Standard Deviation and VarP for Variance. (It might not make full sense in this post, but I added them anyway to see how we can apply for formula 😊 I’m sure your use-case will make more sense!)

SharePoint List

Let’s say, my SharePoint list looks like this. Scores of some people and their ranks

And I’m using Data Table to populate this into my Canvas Power App

Formulas

Here’s how I used for Formulas to use the Aggregate functions on the SharePoint list data I populated in my Canvas Power App

For all the Formulas above, I’ve written them inside a Concatenate function just so I could add some Text and then use the formulas. You may use differently.

In my case, the Formula goes like this –
Function(SharePointListName, ColumnName)

“Max” – Maximum Number in Score column of Scoreboard list


“Min” – Smallest Number in Score column of Scoreboard list

“Sum” = Total of all values in Score column of Scoreboard list

“Average” – Average of all values in Score column of Scoreboard list

“StdevP” – Standard Deviation arguments passed. Score column in this case

“VarP”-Variance of the arguments passed. Score column in this case

And that’s it! I tried to simply the explanation. However’s there much more to consider as well. Here’s the full documentation by Microsoft – https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-aggregates

You might want to check some posts on Canvas Power Apps as well –

  1. Count of total CDS records returned in a Canvas Power App connection [Quick Tip]
  2. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  3. Restore older version of a Canvas Power App | Power Platform
  4. Implement character length validation in a Canvas Power App | Power Platform
  5. Logged In User details in a Canvas Power App
  6. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  7. Variables in Canvas Power Apps | Global and Context
  8. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  9. Sending Image from Canvas PowerApps to SharePoint Document Library using Flows
  10. Correctly connect to an Excel file in a Canvas PowerApp

Hope this was helpful!

Count of total CDS records returned in a Canvas Power App connection [Quick Tip]

Like in Dynamics 365, you see a total number of records under a view. And you want similar in a Canvas PowerApp too.
undefined

Here’s a simple tip to do so –

CountRows() method

It’s pretty simple. Using CountRows(source) method, you can get the count of records in the Source. In this case, it’s the CDS entity Accounts.
undefined

To flourish how I display the count, I use the Concatenate() method and then use CountRows() inside it first show the text and then the actual count.

Please note that this goes without filtering out any criteria and straight count of how many records the connection has. Your gallery could use more filtering to display lesser records if specified that way.

Handle Delegation

However, you need to handle a few things if you’re aware that your dataset is large.

Using this formula will give a warning:
undefined

And the general help offered is this –
undefined

Refer this article to understand more: https://powerapps.microsoft.com/en-us/blog/powerapps-data-row-limit-for-non-delegable-queries/

Hope this quick tip helps!

Here are some more Canvas PowerApp / Power Automate posts you might want to look at –

  1. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  2. Restore older version of a Canvas Power App | Power Platform
  3. Implement character length validation in a Canvas Power App | Power Platform
  4. Logged In User details in a Canvas Power App
  5. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  6. Variables in Canvas Power Apps | Global and Context
  7. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  8. Get Count of records retrieved in CDS connector in a Flow | Power Automate

Thank you!