' Group By ' with Power Automate

Context

We need to send an email to each user containing all the applications they have created. We will proceed by grouping the applications by user.

Steps

To achieve this, we have created a table called "User Application" that contains all the applications created in an environment.

UserEmail Application Name
[email protected] TEST DEV - TEST FHR - Merge REC 4
[email protected] TEST DEV - TEST FHR - MERGE REC 8
  • Create an instant flow
  • List the rows of the table "User Application"
  • Initialize the variable 'Notifications Results' as an array.
    User Application
  • Initialize the variable 'Unique Emails' as an array.
    Unique Emails
  • In an 'Apply to Each', add the Compose operation and the following expression.
    union(variables('Unique_Emails'), createArray(item()?['UserEMail']))
  • Set the variable 'Unique Emails' to the output of the Compose.
    Output
  • Add a new 'Apply to Each' with the variable 'Unique Emails' to process its content.
  • Add a compose action with the current item.
    Current item
  • Now we want to collect all the applications created by each user.
  • Add a filter action: from the "User Application" value. equals(item()?['UserEmail'], outputs('Email'))
  • Add a select action to grab the EMAIL User and the application name.
    Email User
  • Add to the array variable 'Notifications resultats' the Email User and AppName.
    Notifications resultats
  • Create an HTML table with the variable content as input.
    HTML Table
  • Send an e-mail to each user and add the html table to the body of the email.
    Email
  • Each user will receive an email with an HTML content table.
    Content table


Similar Articles