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 / Populating a gallery b...
Power Apps
Answered

Populating a gallery based on manually input text

(0) ShareShare
ReportReport
Posted on by 716 Moderator

This is a pretty simple ticket app built using a Powerapps template.

 

There is a FilterGallery and TicketsGallery on the Dashboard page.

 

FilterGallery sets the Context variables with:

 

If(ThisItem.TicketTypes="All tickets",
 UpdateContext({type:"All"}),
 ThisItem.TicketTypes="New tickets",
 UpdateContext({type:"New"}),
 ThisItem.TicketTypes="Tickets in progress",
 UpdateContext({type:"In progress"}),
 ThisItem.TicketTypes="Tickets closed",
 UpdateContext({type:"Closed"}),
 ThisItem.TicketTypes="Tickets on hold",
 UpdateContext({type:"On hold"}),
 ThisItem.TicketTypes="Tickets older than 3 days",
 UpdateContext({datetype:Text(DateAdd(Today(), -3)),type:"Tickets older than 3 days"}),
 ThisItem.TicketTypes="Tickets closed today",
 UpdateContext({datetype:Text(Today()),type:"Tickets closed today"}),
 ThisItem.TicketTypes="Tickets opened today",
 UpdateContext({datetype:Text(Today()),type:"Tickets opened today"}))

 

And the TicketsGallery displays with:

 

If(type="All",Tickets,
 If(type="Tickets older than 3 days", Filter(Tickets, DateCreated <> datetype && DateCreated <>Text(Today()), DateCreated <> Text(DateAdd(Today(), -2)),DateCreated <> Text(DateAdd(Today(), -1))|| DateClosed <> datetype && DateClosed <> Text(Today()), DateClosed <> Text(DateAdd(Today(), -2)),DateClosed <> Text(DateAdd(Today(), -1))),
 If(type="Tickets opened today",Filter(Tickets,datetype in DateCreated),
 If(type="High Priority Tickets",Filter(Tickets,Priority = "High"),
 If(type="Tickets closed today",Filter(Tickets,datetype in DateClosed),Filter(Tickets,type in Status))))))

 

 

But I have two challenges to now overcome that I cannot figure out on my own.

 

1. I don't understand why the context variable is not showing on the Variables page but seems to be setting correctly. I added a Button to the left of the field that sets MySearchText to the input text and that is working because I can run the app, enter a value, click the button and then when I return to edit mode, I can see the MySearchText value has updated. Note: In order to have "Enter text here" display at page load and disappear OnSelect, MySearchText is set during OnVisible to "Enter text here" and the Default for the InputText control has it's Default set to MySearchText. And the Default changes after clicking my little execute button.

 

2. Since MySearchText is set, how do I then use the MySearchText string in the Gallery query to collect and display any Tickets where Tickets.Description contains MySearchText.

 

And thanks everyone for the help.

 

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,119 Most Valuable Professional on at

    Hi @DCHammer ,

    What are you referring to as the "Variables page" - Context Variables only exist on the screen they are created. For a start, you can cut the first bit down

    UpdateContext(
     { 
     type:
     Switch(
     ThisItem.TicketTypes,
     "All tickets",
     "All",
     "New tickets",
     "New",
     "Tickets in progress",
     "In progress",
     "Tickets closed",
     "Closed",
     "Tickets on hold",
     "On hold",
     "Tickets older than 3 days",
     "Tickets older than 3 days",
     "Tickets closed today",
     "Tickets closed today",
     "Tickets opened today",
     "Tickets opened today"
     ),
     datetype:
     Switch(
     ThisItem.TicketTypes,
     "Tickets older than 3 days",
     Text(DateAdd(Today(), -3)),
     "Tickets closed today",
     Text(Today()),
     "Tickets opened today",
     Text(Today())
     )
     }
    )

    and the Filter (note I have made no attempt to interpret your logic here - just tried to give you the required structure)

    With(
     {
     _T2: Text(DateAdd(Today(), -2)),
     _T1: Text(DateAdd(Today(), -1)),
     _T: Text(Today())
     },
     With(
     {
     _Data:
     Filter(
     Tickets,
     type="All" ||
     (
     type = "Tickets older than 3 days" && 
     (
     (
     DateCreated <> datetype && 
     DateCreated <> _T &&
     DateCreated <> _T2 &&
     DateCreated <> _T1
     ) || 
     (
     DateClosed <> datetype && 
     DateClosed <> _T && 
     DateClosed <> _T2 &&
     DateClosed <> _T1
     )
     ) ||
     (
     type = "Tickets opened today" &&
     datetype in DateCreated
     ) ||
     (
     type = "High Priority Tickets" &&
     Priority = "High"
     ) ||
     (
     type="Tickets closed today" &&
     datetype in DateClosed
     ) ||
     type in Status
     )
     )
     },
     Search(
     _Data,
     SearchText.Text,
     "Description"
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • DCHammer Profile Picture
    716 Moderator on at

    What you're suggesting may in fact work but I can't translate your suggestion into the specific syntax I need. 

     

    I've attempted to solve it a different way but it isn't working either.

     

    I have added a 'type' value of Search in addition to the other values and set type: Search when the button beside the text box is clicked. 
    That works. Both the 'type' and 'MySearchText' are set properly OnSelect of the button.

     

    I thought I could just add an additional If statement at the end of the Gallery query like this:

     

    If(type="All",Tickets,
     If(type="Tickets older than 3 days", Filter(Tickets,DateCreated <> datetype && DateCreated <>Text(Today()), DateCreated <> Text(DateAdd(Today(), -2)),DateCreated <> Text(DateAdd(Today(), -1))|| DateClosed <> datetype && DateClosed <> Text(Today()), DateClosed <> Text(DateAdd(Today(), -2)),DateClosed <> Text(DateAdd(Today(), -1))),
     If(type="Tickets opened today",Filter(Tickets,datetype in DateCreated),
     If(type="High Priority Tickets",Filter(Tickets,Priority = "High"),
     If(type="Tickets closed today",Filter(Tickets,datetype in DateClosed),Filter(Tickets,type in Status)))))
     If(type="Search",Filter(Tickets,MySearchText,"Description")))

    But that isn't working and it doesn't make sense to me.

     

    I added:

    If(type="Search",Filter(Tickets,MySearchText,"Description"))

    Which broke it. I'm sure I just have messed up the syntax in this statement but can't figure out how to fix it.

  • WarrenBelz Profile Picture
    156,119 Most Valuable Professional on at

    @DCHammer ,

    This part

    If(
     type="Search",
     Filter(
     Tickets,
     MySearchText,
     "Description"
     )
    )

    will certainly not work as it is incorrect syntax - you need the Search() function, however this is not Delegable which is why I pre-filtered your original code using a With() statement. I also notice a couple if in filters which are also not Delegable. I believe you need to look at the structure I posted (as I mentioned, I did not look at your logic), otherwise you will have to add the Search to every one of those conditional filters you are using.

     

  • DCHammer Profile Picture
    716 Moderator on at

    So your response to me is to tell me I'm wrong, point out a number of other places that I'm wrong and refer me back to your original response which was not helpful.

    I'm well aware almost every query is non-delegable and DON'T CARE. This tool is never going to be around long enough to hit the 2000 record limit. And if it does, we'll purge data to stay under the limit.

     

    So I guess I'll mark this whole thing unresolved and attempt another post.

  • Verified answer
    WarrenBelz Profile Picture
    156,119 Most Valuable Professional on at

    @DCHammer ,

    The part you did not mention until now was that your list will never be over your Delegation limit. When I respond I do not know your skill/experience level and therefore always try to provide Delegable solutions and guidance on what is Delegable (which the vast majority of people are grateful for). If you want to get rid of the Delegation issue and your list will always be under the limit, do this

    With(
     {_Tickets: Tickets},
     Filter(
     _Tickets,
     . . . . .
    

    As I mentioned before, if you are going to use your current structure, you will need to add the Search() to each one of the Filters, which is why I provided the syntax combining then all.

     

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 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard