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 / Searching a nonexistan...
Power Apps
Answered

Searching a nonexistant or blank collection

(0) ShareShare
ReportReport
Posted on by 18

I have an app that is scanning barcode numbers into a collection and looking up data. Where I'm stuck is on the first item. How can you search a "Code" column on the first scan if the collection has not added the first item yet. 

 

I've tried doing ClearCollect(colScannedStuff, Blank()), but is there a way to get a named column to search but the collection still be empty? Or is there a better way to go?

 

The goal is to take scans of additional of the same items and increment a quantity rather than duplicate the line. Prior to Collecting, do a lookup to see if it's there already. If so, add to the quantity column.

 

Categories:
I have the same question (0)
  • Verified answer
    AnthonyD Profile Picture
    559 on at

    I would do the following:

    Initiate a collection colScannedStuff with ClearCollect(colScannedStuff, Blank()) onStart of your app.

    Then later use the following code to add items to the collection if they don't exist. Or update the quantity if they do exist.

    If(
     !IsBlank(colScannedStuff) And !IsBlank(
     LookUp(
     colScannedStuff,
     Barcode = Scanner.Text
     )
     ),
     Patch(
     colScannedStuff,
     LookUp(
     colScannedStuff,
     Barcode = Scanner.Text
     ),
     {
     Barcode: Scanner.Text,
     Quantity: LookUp(
     colScannedStuff,
     Barcode = Scanner.Text
     ).Quantity + 1
     }
     ),
     Collect(
     colScannedStuff,
     {
     Barcode: Scanner.Text,
     Quantity: 1
     }
     )
    )


     Please accept this answer as a solution if this answer solved your question.

    Best Regards,
    Anthony

  • TheHockeyGeek Profile Picture
    18 on at

    I was close! I had to add the additional !IsBlank and the 

    Quantity: LookUp(
     colScannedStuff,
     Barcode = Scanner.Text
     ).Quantity + 1

    was formatted wrong. I didn't have the lookup for Quantity. Thanks!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 392

#2
WarrenBelz Profile Picture

WarrenBelz 364 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 271 Super User 2026 Season 1

Last 30 days Overall leaderboard