user27576724
user27576724

Reputation: 1

PowerApps how do I filter or search a custom Gallery field?

I have a folder with hundreds of PDF files that I get from customers. I keep track of the customer each file belong to by adding a unique ID at the front of every filename followed with a hyphen. I then have an excel master list where I keep track of the latest name for each customer and their unique ID. Goal now was to create a database that users could access all the files that I saved. Overall goal is now to create a library of all the pdf files where users could also see the customer names or any fields I might decide to add (e.g., date processed, date modified, etc..).

I decided to try Power App. My first data source is the folder to all my pdf files. My Second data source is the excel master list table.
(See example 1 for data sources)

Example 1: Data sources

So far, I created a gallery with multiple text labels as columns (Unique ID, Customer name, Filename, Download image):

(See example 2 for example of Gallery results)

Example 2: Results

Here is the challenge:

In the gallery Im only able to figure out how to search for text within the filenames. I cant for the life of my figure out how to filter for the [Unique ID] and [Customer name] I created in the gallery.

Example:

Formulas/functions I tried but nothing works:

Search(Gallery1,Txt_Search.Text, UniqueID)
Search(Gallery1,Txt_Search.Text, UniqueID.value)

Upvotes: 0

Views: 88

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87228

If you create a table that has all the columns which you want to search, then you can use that in the Items property of the gallery with the appropriate Search expression. It should be something similar to the code below:

Search(    // (3)
    AddColumns(    // (2)
        AddColumns(     // (1)
            Filenames,
            UniqueID,
            Trim(First(Split(FileName, "-")).Value)
        ) As FromFile,
        'Customer Name',
        LookUp(
            MasterList,
            ThisRecord.UniqueID = FromFile.UniqueID,
            'Customer Name'
        )
    ),
    Txt_Search.Text,
    UniqueID,
    'Customer Name',
    FileName
)

In the expression above, we:

  1. First (1) add an additional column to the list of file names (notice that the original data source is not changed; this column is added on the fly by this expression) with the unique id extracted from it
  2. Then (2) add another column with the customer name from the other table. At this point we have a table with the three columns for which you want to search
  3. Finally (3) we search the created table with the value from the text input control for all columns that you want searched.

Upvotes: 0

Related Questions