cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hzer
Regular Visitor

Use column values in document library to populate combo box

Hi everyone,

I'm working on an application which can be used to search files in a document library based on tags which a user submits when they upload a document.  For example, a user could upload a word document containing weather information and tag it "Weather", "Precipitation", "Wind", etc.   "Tags" is a column in my document library that holds the user submitted tags for each document.  An image of my application so far, and my document library layout,  is attached to this post. 

 

I want to create a combo box which will allow the user to select a number of tags (from the document library column information), that can be used to filter the documents presented in the gallery below.  Ideally the combo box options should be searchable as well (ie. if i type "We" this should show me tag options like "We", "Welcome", "Wednesday", etc).

 

Looking for any help/recommendations on how this could be done.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AJ_Z
Super User
Super User

Hey @hzer 

 

So i have built a dummy version  of your app and datasource.

i called my datasource: 'Power App Test'

i called the column with the tags in: 'test text'
i called the combobox which will select tags that i will use to filter the gallery: ComboBox1

first i have a List with tags in a column broken up by spaces:

AJ_Z_1-1641677119233.png

 

 

then i am working under the assumption that we have a predefined list of tags so i add a combobox and in its items i add my list of possible tags:

AJ_Z_2-1641677380187.png

 

i then go to my gallery and tweak the filter to be: 
Filter('Power App Test',ComboBox1.Selected.Value in 'test text')


I then want to make sure my combobox is searchable so i go to it properties an i turn on this:

AJ_Z_3-1641677608717.png

 

Now then imagine there is no predetermined list of tags and users are evil and choose to create loads of tags. It would be super tedious for your to keep coming into the app and adding all there new tags as options in the Combobox. Do not worry i got your back in that case we are going to switch things up. 

 

I want you to add this to either the OnStart or the Onvisible of your app whichever makes more sense for your app. For my app i chose to put it in the OnStart.:

 

 

ForAll(
    'Power App Test'.'test text' As RecSplit,
    ForAll(
        Split(
            RecSplit.'test text',
            Char(32)
        ) As tagsplitted,
        Collect(
            Tags,
            {TagChoices: tagsplitted.Result}
        )
    )
)

 

 

Now go back to our ComboBox1 we will be changing it's Items to this:

Distinct(Tags.TagChoices,TagChoices)

 

AJ_Z_4-1641677964490.png

 

then we need to go back to the gallery and change it's filter to this:

Filter('Power App Test',ComboBox1.Selected.Result in 'test text')

 

Okay now Delegation is a potential issue due to the In within the filter.
For me this is not a problem as I have less than 500-2000 rows of data but what if it is an issue? in that case I would collect a filtered down list for your gallery e.g. maybe users only need to see rows Created in the last 30 days. Alternatively we can collect in  batches perhaps.

 

Also don't forget to change my datasource and columns names to be your ones where applicable.

 

Also please forgive my typing if there are errors as i am currently on a train 🙂



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

View solution in original post

5 REPLIES 5
AJ_Z
Super User
Super User

I noticed your tags appeared to be one word and separated by a single space will that always be the case? The reason i ask is because any solution that immediately comes to my mind relies on the Split() function so it would be important to understand the delimiter which can be a space but is usually a comma or semi-colon. 



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

hzer
Regular Visitor

Thanks for the quick response! Yes, how the tags will be formatted/submitted is in my control.  Right now I have the separator as a blank space and this will always be the case unless I change the delimiter myself. 

AJ_Z
Super User
Super User

Hey @hzer 

 

So i have built a dummy version  of your app and datasource.

i called my datasource: 'Power App Test'

i called the column with the tags in: 'test text'
i called the combobox which will select tags that i will use to filter the gallery: ComboBox1

first i have a List with tags in a column broken up by spaces:

AJ_Z_1-1641677119233.png

 

 

then i am working under the assumption that we have a predefined list of tags so i add a combobox and in its items i add my list of possible tags:

AJ_Z_2-1641677380187.png

 

i then go to my gallery and tweak the filter to be: 
Filter('Power App Test',ComboBox1.Selected.Value in 'test text')


I then want to make sure my combobox is searchable so i go to it properties an i turn on this:

AJ_Z_3-1641677608717.png

 

Now then imagine there is no predetermined list of tags and users are evil and choose to create loads of tags. It would be super tedious for your to keep coming into the app and adding all there new tags as options in the Combobox. Do not worry i got your back in that case we are going to switch things up. 

 

I want you to add this to either the OnStart or the Onvisible of your app whichever makes more sense for your app. For my app i chose to put it in the OnStart.:

 

 

ForAll(
    'Power App Test'.'test text' As RecSplit,
    ForAll(
        Split(
            RecSplit.'test text',
            Char(32)
        ) As tagsplitted,
        Collect(
            Tags,
            {TagChoices: tagsplitted.Result}
        )
    )
)

 

 

Now go back to our ComboBox1 we will be changing it's Items to this:

Distinct(Tags.TagChoices,TagChoices)

 

AJ_Z_4-1641677964490.png

 

then we need to go back to the gallery and change it's filter to this:

Filter('Power App Test',ComboBox1.Selected.Result in 'test text')

 

Okay now Delegation is a potential issue due to the In within the filter.
For me this is not a problem as I have less than 500-2000 rows of data but what if it is an issue? in that case I would collect a filtered down list for your gallery e.g. maybe users only need to see rows Created in the last 30 days. Alternatively we can collect in  batches perhaps.

 

Also don't forget to change my datasource and columns names to be your ones where applicable.

 

Also please forgive my typing if there are errors as i am currently on a train 🙂



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

hzer
Regular Visitor

Thanks, everything worked perfectly! For some reason, the collection wasn't populating when I had the function run OnStart.  I switched it to OnVisible and everything's good.  Thanks again

AJ_Z
Super User
Super User

Hey @hzer For it to appear on start you have to reload the app or if in studio editor press run onstart and I am glad it worked and was a solution for you 🙂. Please make sure to click accepts as solution next to it to mark it as the solution so others can find it easily 🙂



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (5,028)