web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / remove duplicated records
Power Apps
Answered

remove duplicated records

(0) ShareShare
ReportReport
Posted on by 63

I have the next code which takes names in outlook format and producing emails of managers of the employees.
I want the code to remove duplicate results.
I'll be glad to help with that.

 

 

Concat(
ForAll(
Split(TextInput1.Text, ";"),
{
EmployeeData: Value
}
),
Office365Users.ManagerV2(Match(EmployeeData, "<(?<email>[^>]*)>").email).mail,
";" & Char(10)
)

Categories:
  • Chris-D Profile Picture
    1,246 on at

    Hi @cabutbul, I'm assuming your email addresses are in your TextInput1 control here but you can use the Distinct() function to return only unique values:

    Concat(
     ForAll(
     Distinct( Split(TextInput1.Text, ";"), Value),
     { EmployeeData: Value }
     ),
     Office365Users.ManagerV2( Match(EmployeeData, "<(?<email>[^>]*)>").email).mail,
     ";" & Char(10)
    )
  • cabutbul Profile Picture
    63 on at

    Thanks, but I get the following error:
    "The function manager2 has an invalid value for parameter id  - a blank value was passed to it where it was not expected.., 

  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi @cabutbul 

     

    Try this

     

    Concat(
    Distinct(
    ForAll(
    Split(TextInput1.Text, ";"),
    {
    EmployeeData: Value
    }
    ),
    EmployeeData
    ),
    Office365Users.ManagerV2(Match(EmployeeData, "<(?<email>[^>]*)>").email).mail,
    ";" & Char(10)
    )

    (Or)

     

    Concat( 
    Distinct(
    ForAll(
    Split(TextInput1.Text, ";"),
    { EmployeeData: Value, ManagerEmail: Office365Users.ManagerV2(Match(EmployeeData, "<(?<email>[^>]*)>").email).mail
    }
    ), ManagerEmail
    ), ";" & Char(10)
    )

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • Verified answer
    Chris-D Profile Picture
    1,246 on at

    This could happen if there are blanks in your input string, you can filter them out like this. 

    Concat(
     Filter(
     ForAll(
     Distinct( Split(TextInput1.Text, ";"), Value),
     { EmployeeData: Value }
     ),
     !IsBlank( EmployeeData)
     ),
     Office365Users.ManagerV2( Match(EmployeeData, "<(?<email>[^>]*)>").email).mail,
     ";" & Char(10)
    )

     

    Otherwise it's likely your Match() isn't matching anything and returning blank. 

  • cabutbul Profile Picture
    63 on at

    Sorry but there is no changes on the results.

    Still have duplicated values

  • cabutbul Profile Picture
    63 on at

    Sorry but Both have errors.

  • cabutbul Profile Picture
    63 on at

    It's not working.

    It is important to note that the intention is not to search for duplicate records of employees but duplicate records of managers (there may be different employees with the same manager), I want to reduce the duplicate results.

  • Chris-D Profile Picture
    1,246 on at

    I see. I'm assuming the Office265Users.ManagerV2 function here returns the users' managers. 

     

    Try this, I've commented each part so hopefully you can see what's going on. I've moved the lookup for the users manager into the first argument of Concat. Concat is now processing the list of managers rather than the list of employees.

    Concat(
     // This Distinct removes duplicates from the managers emails
     Distinct(
     // This ForAll looks up managers emails from the employee emails
     ForAll(
     // This Filter removes blanks from the employee email list
     Filter(
     // This Dintinct removes duplicates from the employee email list 
     Distinct( 
     Split(TextInput1.Text, ";"), 
     Value
     ),
    
     // Filter allows non blank values
     !IsBlank( Value)
     ),
    
     // Inside of the ForAll loop, employee email is stored in Value
     {
     // Store the name of the manager to ManagerEmail
     ManagerEmail: Office365Users.ManagerV2( 
     Match( Value, "<(?<email>[^>]*)>").email
     ).mail
     }
     ),
    
     // Inside Distinct
     ManagerEmail
     ),
    
     // Inside Concat
     ManagerEmail,
     ";" & Char(10)
    )

     

  • cabutbul Profile Picture
    63 on at

    I still got an error.
    I edit the code to consider blank results, but still need to filter duplicated results.

    It is important to note that the intention is not to search for duplicate records of employees but duplicate records of managers (there may be different employees with the same manager):

    Concat(
          ForAll(
                 Split(TextInput1.Text, ";"),
                {
                      EmployeeData: Value
                }
      ),
      If(
           !IsBlank(Match(EmployeeData, "<(?<email>[^>]*)>").email),
           Office365Users.ManagerV2(Match(EmployeeData, "<(?<email>[^>]*)>").email).mail,
            "" // Handle the case where the email is blank or invalid
        ),
        ";" & Char(10)
    )

  • Chris-D Profile Picture
    1,246 on at

    Please see my code example above. If you want to check for blank manager emails then just wrap the whole thing in another filter in the same way I use it to filter blanks from the employee email list. 

     

    Although you should consider what will happen if the manager email cannot be found. That manager won't get an email. Is that a problem? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard