cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
deharris
Level: Powered On

Filter a Gallery based on whether the item is in another gallery

I have two galleries:  One (gallery2) is data from a sequel connection that I filter for customers in my own area.  The other (Gallery1) is a smaller, manually maintained subset of customers in my area that are a subset of customers frmo the sequel connection (our focus customers).  My users will update data for the customers in Gallery1 but I want them to have the option to update data in for items in Gallery 2 as well.  They would complete Gallery1 updates first.  How can I filter the Gallery2 items to not show the Gallery1 items?  They both have a CustomerID in common.

thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Filter a Gallery based on whether the item is in another gallery

Hi @deharris,

If I am understanding you correctly, you want to filter a second gallery and eliminate all the items in the first gallery.  Each gallery is based on a separate datasource that has customerID in common.  You could do something along these lines as the Items property for Gallery2:

Filter(Table2, Not(customerID in Table1.customerID))

Assuming Table1 is the datasource for Gallery1 and Table2 is the datasource for Gallery2.  

 

As an alternative, and provided that there is a one-to-one relationship between these two tables, could you combine them into a single table and add a field called FocusCustomer (Yes/No)?  Then you could filter on that field.  You could also have two entry forms, each one with the same data source but with fields specific to each group of users.

 

8 REPLIES 8
Super User
Super User

Re: Filter a Gallery based on whether the item is in another gallery

Hi @deharris,

If I am understanding you correctly, you want to filter a second gallery and eliminate all the items in the first gallery.  Each gallery is based on a separate datasource that has customerID in common.  You could do something along these lines as the Items property for Gallery2:

Filter(Table2, Not(customerID in Table1.customerID))

Assuming Table1 is the datasource for Gallery1 and Table2 is the datasource for Gallery2.  

 

As an alternative, and provided that there is a one-to-one relationship between these two tables, could you combine them into a single table and add a field called FocusCustomer (Yes/No)?  Then you could filter on that field.  You could also have two entry forms, each one with the same data source but with fields specific to each group of users.

 

deharris
Level: Powered On

Re: Filter a Gallery based on whether the item is in another gallery

Thank you for for the response and you have the mission correctly defined.  I've moved the data sources to 2 collections since the sequel data table is thousands of records.  The second data source is about 900.  I tried your formula suggestion with the 2 collections and I get an error:  "Name isn't valid. This identifier is recognized.  This error appears most commonly when a formula refers to something that no longer exists."

 

Here's what I have in place.  Collection1 (Sequel lengthy list) & Collection2 (smaller 900 list of which all CustomerIDs appear somewhere in Collection1.  This is the formula that gets me the error above.

 

Filter(Collection1, Not(CustomerID in Collection2.CustomerID))

 

thank you for any assistance

deharris
Level: Powered On

Re: Filter a Gallery based on whether the item is in another gallery

It's working now!  for some reason, the data didn't immediately appear.  After I closed the app and reopened, it appears to be pulling it together.

thank you @Drrickryp

Super User
Super User

Re: Filter a Gallery based on whether the item is in another gallery

Hi @deharris,

You may be running into a delegation problem with the collection on the larger list.  Put a label somewhere on the screen and set it's Text property to CountRows(Collection1) and check to see if you are getting all the rows that are in the data source. 

PS: I just saw that it is working.  It's probably a good idea to double check and make sure that your collection is getting all of the records in the bigger table.  If it is getting close to 2000 you will need to do something else to make sure the formula works right.

deharris
Level: Powered On

Re: Filter a Gallery based on whether the item is in another gallery

@Drrickryp

You are correct, stalled at the 2000 limit.  I don't believe I'm using any non-delegable functions.  I filter the Sequel list with 5 simple column filters and the final collection should be about 6,700 items (but can change, hence the need to connect to an active data source).  I've tried removing filters and still only get the 2000.

 

ClearCollect(Collection1,(Filter(Sequel Name,State=12,PremiseCode=1,ChainID<>920004680,CustomerClassName<>"Supplier",StatusID<>"N")))

 

any thoughts?

many thanks

Super User
Super User

Re: Filter a Gallery based on whether the item is in another gallery

@deharris,

What is the connector?  Sql, Sharepoint, Excel or some other one? 

deharris
Level: Powered On

Re: Filter a Gallery based on whether the item is in another gallery

@Drrickryp

Collection 1 is a sequel connection.  I simply typed out the phrase "Sequel Name" in the formula I shared previously.

 

ClearCollect(Collection1,(Filter(Sequel Name,State=12,PremiseCode=1,ChainID<>920004680,CustomerClassName<>"Supplier",StatusID<>"N")))

Super User
Super User

Re: Filter a Gallery based on whether the item is in another gallery

@deharris,

 

All the functions in your formula are delegatable in Sql except for Collect and ClearCollect.  Thus, any collection you create will only keep the first 2000 records.  That isn't a problem for the small table but running a Collect() against the big table with >6000 records will only return the first 2000 records.  To create a collection against the large table, you would need to split it into at least 4 separate collections and then combine them. CountRows() is not delegatable so if you run it against the datasource itself it will max at 2000 and not give an accurate count of the records. However, if you run it against a collection created by combining other collections, it will accurately reflect the number of records in that collection.

However, you can run any of the functions against the datasources themselves.  Thus, if Gallery2 has the formula that I gave you in the first place, 

Filter(Table2, Not(customerID in Table1.customerID))

and if you replace the Table names with the actual datasources, the gallery should contain all of the records and a Search of the Items in the gallery should be accurate. For example if the Items property of Gallery2 was 

Search(Filter(Table2, Not(CustomerID in Table1.CustomerID),Textinput1.Text,"Field1","Field2")

 The gallery should show all records containing matching text from a TextInput control named Textinput1 in two Fields in Table2.  Say "Field1" was "CustomerName" and "Field2" was "CustPhone", Entering any part of the Customers name or Phone number in the TextInput box would result in only Customers who matched the Search terms being displayed in the gallery. For additional information about delegation, please see @tchin-nin 's excellent blog post in the Community Blog.