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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Can you filter a label...
Power Apps
Answered

Can you filter a label you added to your gallery?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Good evening,

 

I added a label inside a gallery that calculated distance between a column inside the gallery and a user input box. I would like to filter the gallery base on that label but it's not a column...

 

How would you do it?

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

    You can set the Items of your Gallery to something like this

     

    Filter(AddColumns(OriginalItemsExpression, "Distance", expression to calculate distance), Distance < 100)

     

    Regards,

    Pat

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    This is impossible in theory, but I have a small trick.
    The point is to create an auxiliary collection,I've made a test for your reference:

    1\I assume your gallery's data source is-GalleryItems

     

    ClearCollect(
    GalleryItems,
    {ID:1},{ID:2},{ID:3},{ID:4},{ID:5})

     

    2\Add a Text Input control (TextInput1)

    3\Add a Gallery(Gallery3)

     

    If(
     IsBlank(TextInput1.Text),
     GalleryItems,
     Filter(
     GalleryItems,
     TextInput1.Text in LookUp(
     MyCollection, /*MyCollection is my coustom collection I'll show you how to define it later*/
     ID = GalleryItems[@ID]
     ).Text
     )
    )

     

    4\Add a text input control(TextInput2) into Gallery3

    OnChange

     

    RemoveIf(
     MyCollection,
     ID = ThisItem.ID
    );
    Collect(
     MyCollection,
     {
     ID: ThisItem.ID,
     Text: TextInput2.Text
     }
    )

     

    Default 

     

    LookUp(MyCollection,ID=ThisItem.ID).Text

     

    17.gif

    Although your requirement is to calculate the distance(I can’t test because you didn’t provide details), the principle is the same.

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-bofeng-msft 

     

    Questions... 

     

    Where do you put : 

     

    .

    ClearCollect(
    GalleryItems,
    {ID:1},{ID:2},{ID:3},{ID:4},{ID:5})

    And,

     

    By saying gallery(gallery3) means you have a gallery inside a gallery ?

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    Q1:

    GalleryItems is my custom collection.It is my data source for testing.You should use your own data source instead of following my step 1.

    Q2:

    gallery3 is my own gallery for test it's not an embedded gallery.

    In addition,because you only asked the question without describing the specific details of your app, I can't provide you with suggestions based on your app. I suggest you read the solution I provided to understand its principle and apply it to your own app.

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-bofeng-msft 

     

    Sorry for the late response, I'm trying exactly what you wrote and it doesnt work. I tried understand what you used and I understand everything except the following : 

     

    GalleryItems,
    TextInput1.Text in LookUp(
    MyCollection,
    ID = GalleryItems[@ID]
    ).Text

     

    The part that bugs me is ID = GalleryItems[@ID], what does it refer to ? Some sort of new variable ? Is it a column in my collection that I'm missing maybe...

     

    And If I remove this, the gallery start working fine. Can you explain what this does ? And again, sorry for the late response.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Somehow I managed to get it to work, but still confuse into this formula...


    ID = GalleryItems[@ID]
    ).Text

     

    What is the .text refering too ?

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    The function of GalleryItems[@ID] is to eliminate ambiguity. Because GalleryItems and MyCollection both contain columns named ID. So you need to use this syntax to distinguish which table the ID used for comparison comes from.

    I think this link will help you a lot:

    Disambiguation operator 

    Best Regards,

    Bof

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard