cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JamesM
Level 8

Remove items from Gallery based on value of label within Gallery item.

I have a Gallery of items. all of the controls within each gallery item are based on a single collection - allStoreSales. There is however, one label within each item (see screenshot below, the 'STORE_TRADING' label) which is sourced from a different collection called storeStateCollection.

 

forum1.png

 

The code for the store trading label within each gallery item is: 

 

LookUp(storeStateCollection,ServerName=ThisItem.ServerName).ProcessNextState

As you can see, the label looks up the processNextState value based on the server name within the gallery item. 

 

Now, my issue. I want to REMOVE all items from this gallery, where the processNextState within the storeStateCollection is NOT STORE_TRADING. I'm unsure how to do this, as the items are mostly made up from a different collection. How can I do this? 

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Level 10

Re: Remove items from Gallery based on value of label within Gallery item.

@JamesM

 

Try this

Filter(AddColumns(allStoreSales, "NextStat", LookUp(storeStateCollection,ServerName=ThisItem.ServerName).ProcessNextStat)
	, NextStat = "STORE_TRADING"
)

AddColumns adds the field to your dataset, which you then can filter on that field. This should work I would think.

 

Paul 

3 REPLIES 3
KroonOfficeSol
Level 10

Re: Remove items from Gallery based on value of label within Gallery item.

@JamesM

 

I think you want to remove the items from allStoresSales and you can use something like this.

Remove(allStoreSales, Filter(allStoreSales, !(ServerName="STORE_TRADING")))

But why not just a filter instead off removing from the gallery. Like

Filter(allStoreSales, !(ServerName="STORE_TRADING"))

The gallery will now not show the other states.

 

Hope this helps.

 

Paul

JamesM
Level 8

Re: Remove items from Gallery based on value of label within Gallery item.

This

 

Filter(allStoreSales, !(ServerName="STORE_TRADING"))

Won't work for me, as allStoreSales doesn't contain the 'STORE_TRADING' value. That's my problem. If you read the original post (and apologies if I wasn't clear) the allStoreSales items makes up most of the components in each Item within the gallery EXCEPT the 'STORE_TRADING' field, which is derived from a seperate collection, using the ThisItem.ServerName as a filter (from the allStoreSales collection). 

 

So I want to remove items from the gallery but based on the field which can be 'STORE_TRADING' or 'STORE_CLOSED' etc (which itself is derived from a different collection). 

 

I've worked around this issue by filtering out these items via a SQL view instead, but it'd be worth knowing if this is possible in PowerApps directly (essentially, filtering out items in a gallery based off the value of a field from a control WITHIN The gallery item that isn't associated to the Galleries items collection)

KroonOfficeSol
Level 10

Re: Remove items from Gallery based on value of label within Gallery item.

@JamesM

 

Try this

Filter(AddColumns(allStoreSales, "NextStat", LookUp(storeStateCollection,ServerName=ThisItem.ServerName).ProcessNextStat)
	, NextStat = "STORE_TRADING"
)

AddColumns adds the field to your dataset, which you then can filter on that field. This should work I would think.

 

Paul 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 76 members 4,508 guests
Please welcome our newest community members: