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 / Lookup inside patch an...
Power Apps
Answered

Lookup inside patch and forAll, result all the same

(0) ShareShare
ReportReport
Posted on by 26

Hi, I'm new in powerapps
can somebody help me 

I try to make a collection with using lookup another collection to make value if it finds specific id 
But the result is not what I expected. It result all the row in column "return" is same, 
Even if I check it one by one, it should be different 

Capture.PNGCapture.PNG

If I check from other collection 
it should be:

returnable
returnable
returnable
Non Returnable
Non Returnable
Non Returnable
Non Returnable


is my script wrong when using lookup from different collection?

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dhisss 

    Your trouble comes from the item_code=item_code.  This will always return a true and thus you will get the first record in item_col all the time.

     

    Consider the following formula to replace yours:

    Clear(nd6_stockReport);
    
    With({_user: LookUp(user, email=User().Email},
     ForAll(
     nd6_standart as _nd6,
     Patch(nd6_stockReport,
     Defaults(nd6_stockReport),
     {
     month:Text(_nd6.month_stockcount),
     region: _user.region,
     ship_to: _user.code,
     distributor: _user.name,
     return: _user.return,
     item_code: LookUp(item_col, item_code = _nd6.item_code, return),
     item_name: _nd6.item_name,
     main_stokSistem: Value(_nd6.mainstokSistem)
     }
     )
     )
    );
    Navigate(distributor_home)
    

     

    I hope this is helpful for you.

  • dhisss Profile Picture
    26 on at

    huwaaa, Thank you so much @RandyHayes 
    it works! although you misplace some codes, but I understand the concept and make it works

    Thanks, I also learn how to use "with", and "as" in this powerapps
    I don't know about it before 🙂

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dhisss 

    Yes, I see at least two typos now in the formula.  I do type these all by hand, so I don't get the luxury of the Formula Editor to help 😉

     

    I am glad that this worked for you and that you learned a couple of things.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 396 Most Valuable Professional

#2
11manish Profile Picture

11manish 134 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 101 Super User 2026 Season 2

Last 30 days Overall leaderboard