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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Excract Value from a c...
Power Apps
Unanswered

Excract Value from a collection if object exists if not use ThisItems value

(0) ShareShare
ReportReport
Posted on by 196

Hi,

 

i'm trying to work out how to populate a label in a gallery using the value from a collection if the object is in the collection, and if it isn't use the orignal value from the gallery source. I've tried:

 

 

"Stock Availability: " & If(LookUp(colStockAvailable, ProductsID = ThisItem.ProductID)).AvailableStock, ThisItem.StockAvailability)

 

And

 

"Stock Availability: " & If(LookUp(colStockAvailable, ProductsID = ThisItem.ProductID), AvailableStock, ThisItem.StockAvailability)

 

But I can't seem to just get the value back I want which is AvailableStock. 

 

My collection collects items that are in an orders list based on a date range, in my orders list it works out how much stock is left of those items based on those dates.

 

Any suggestions would be great.


Thanks

Categories:
I have the same question (0)
  • KvB1 Profile Picture
    1,596 on at

    In your If function, you first need to check if the record in the other collection exists using a lookup. If this check returns true, you grab the AvailableStock of that record, If not, you return ThisItem.StockAvailability.

     

    Something like this:

     

     

    "Stock Availability: " &
    If(
    	Len(
    		LookUp(
    			colStockAvailable,
    			ProductsID = ThisItem.ProductID
    		).AvailableStock
     	)>1,
    	LookUp(
    		colStockAvailable,
    		ProductsID = ThisItem.ProductID
    	).AvailableStock,
    	ThisItem.StockAvailability
    )

     

     

  • Verified answer
    CU-18081211-6 Profile Picture
    9,270 Moderator on at

     

    @mousman85 ,

    "Stock Availability: " & 
    Coalesce(
     LookUp(
     	colStockAvailable,
    	ProductsID = ThisItem.ProductID).AvailableStock,
     ThisItem.StockAvailability
    )

    Hope it helps !

     

  • mousman85 Profile Picture
    196 on at

    thanks for the fast repsonse, this worked perfectly! Thanks again. 

  • mousman85 Profile Picture
    196 on at

    Just a further question on this as i've not used the Coalesce function. If i need to update the ThisItem.StockAvailalbity with how much stock they are choosing but not update the back end list is that possible? Something like :

    "Stock Availability: " & 
    Coalesce(
     LookUp(
     	colStockAvailable,
    	ProductsID = ThisItem.ProductID).AvailableStock,
     Lookup(Resource Items, ProductId = Gallery2.Selected.ProductID, ThisItem.StockAvailable - Gallery2.selected.inputtext2.text)
    )

     I know the above won't work just wondering how I can update the ThisItem.StockAvailable, based on how much they have selected, and then return that if the remove it from the other list, I had this working with it patching the main list, but I no longer want to update the master list as I need the availability to be based on dates. Below is a screen grab of the PoC app i'm bulding. when they update the slider it adds it to a collection that shows in the gallery on the right, and when the click the trash can it removes it from the gallery. 

     

    image.png

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard