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 / Add rows only if not a...
Power Apps
Answered

Add rows only if not already present in a Collection

(0) ShareShare
ReportReport
Posted on by 37

Hi All,

 

Need help. I have two collections which I would like to combine. One is colSPList and another colExcel.

 

Sample data from SP List is 

cbroy_22_1-1650822426224.png

 

 

Sample Data from Excel

CodeNameIDStartDate
33Elliot, Erin00344/15/2021
33Daniel, Wilfred45769/15/2020
37Willis, Joy73482/12/2021

 

ClearCollect(
colSPList,
RenameColumns(
ShowColumns(
Filter(
'SP Review',
Code = varCode
),
"Code",
"Name",
"IdNumber"
),
"IdNumber",
"ID"
)
);

ClearCollect(
colExcel,
DropColumns(
Filter(
Listing,
Code = varCode
),
"Code",
"Name",
"ID"
),
"StartDate")
);


What I am trying to achieve is to combine and add details from colExcel only if it is not present in colSPList as below

 

cbroy_22_2-1650823356388.png

 

 

 

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,736 Most Valuable Professional on at

    Hi @cbroy_22 ,

    I cannot test this (and free-typed, so watch commas/brackets etc), but I believe this is the structure you need

    With(
     {
     wSP:
     RenameColumns(
     ShowColumns(
     Filter(
     'SP Review',
     Code = varCode
     ),
     "Code",
     "Name",
     "IdNumber"
     ),
     "IdNumber",
     "ID"
     ),
     wXL:
     ShowColumns(
     Filter(
     Listing, 
     Code = varCode
     ),
     "Code",
     "Name",
     "ID"
     )
     },
     ClearCollect(
     colCombined,
     wSP,
     Filter(
     wXL,
     !(Name in wSP.Name)
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • cbroy_22 Profile Picture
    37 on at

    Thank you @WarrenBelz , this works absolutely fine when I am not bringing in StarteDate. In SharePoint Date is stored in date and time format but in excel its in text format, Whenever I am trying to write combined collect its shows  error

  • Verified answer
    WarrenBelz Profile Picture
    156,736 Most Valuable Professional on at

    Hi @cbroy_22 ,

    You example post did not have the Start Date in and the SharePoint list does not show this field (so I assumed you did not need it), so if the name of the field in SharePoint is Date (a bad name for a field) - 

    With(
     {
     wSP:
     ShowColumns(
     RenameColumns(
     Filter(
     'SP Review',
     Code = varCode
     ),
     "IdNumber",
     "ID",
     "Date",
     "DateStart"
     ),
     "Code",
     "Name",
     "ID",
     "DateStart"
     ),
     wXL:
    	 ShowColumns(
     AddColumns(
     Filter(
     Listing, 
     Code = varCode
     ),
     "DateStart"
     DateValue(StartDate)
     ),
     "Code",
     "Name",
     "ID",
     "DateStart"
     )
     },
     ClearCollect(
     colCombined,
     wSP,
     Filter(
     wXL,
     !(Name in wSP.Name)
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • cbroy_22 Profile Picture
    37 on at

    Thank you, I wasn't sure if DateValue would solve the problem. Agreed Date is a bad name 🙂 , it does prefix which I had to edit, sharepoint list snapshot was incomplete  and apologize I couldn't communicate my requirement first time. Thank you so much for your prompt reply.

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 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard