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 / Need help with filter ...
Power Apps
Answered

Need help with filter on Gallery to try and eliminate delegation warning

(0) ShareShare
ReportReport
Posted on by 176

I have an app i've been working on and you all have helped me so much. I hate to even ask for more help, but i'm stuck again.

 

I have a screen that has a gallery and the gallery needs to be filtered in many different ways. This is the current "Item" filter i have in place:

SortByColumns(Filter('[dbo].[vwGroups]', Switch(TerritoryRadio.Selected.Value,"Parent Only",IsBlank(ParentGroupID),"Child Only",!IsBlank(ParentGroupID),"All",ID) && Territory=TerritoryDrpDn.Selected.Territory, SearchBoxInputTerritory.Text in Name),"Name")

 

I get a delegation warning on the switch function. As you can see, i have 3 radio buttons. I would like to filter the gallery in 1 of 3 different ways. The filter does work, but i'm seeing some problems with it as well. One is the delegation warning. At first i didn't even worry about it. After some time, i've realized that with the switch function in, i'm missing a lot of data that i shouldn't be missing. If the "ALL" radio button is selected, i should see the entire list, but i don't. Some data is just randomly missing from the gallery. If i select child, i'll be missing random data that should be shown as a child, and the same is true if I select parent. I don't know if this is just an inherant problem with using the switch function or what. If anyone has a better way of filtering the data, and could help me, i'd be greatly appreciative.

 

 

Categories:
  • Verified answer
    RezaDorrani Profile Picture
    12,145 on at

    Hi @SeanTambling 

     

    Switch has to be on the outside,

    Alos In is not delegable

    so is IsBlank

     

    try this (u might have to adjust a little)

     

    Switch(TerritoryRadio.Selected.Value,"Parent Only",SortByColumns(Filter('[dbo].[vwGroups]', ParentGroupID=Blank() && Territory=TerritoryDrpDn.Selected.Territory, StartsWith(Name,SearchBoxInputTerritory.Text)),"Name"),"Child Only",SortByColumns(Filter('[dbo].[vwGroups]', ParentGroupID<>Blank()&& Territory=TerritoryDrpDn.Selected.Territory, StartsWith(Name,SearchBoxInputTerritory.Text)),"Name"),"All",SortByColumns(Filter('[dbo].[vwGroups]',Territory=TerritoryDrpDn.Selected.Territory, StartsWith(Name,SearchBoxInputTerritory.Text)),"Name")) 

     

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • SeanTambling Profile Picture
    176 on at

    Your formula worked perfectly!

     

    I have another gallery screen that i've tried to use basically the same formula, but I want to be able to also filter the gallery by they user. It does work but i'm getting a delegation warning. I'm fine if that is unavoidable, but just curious if the formula could be tweaked to keep from having the delegation warning.

     

    Switch(MyGroupsRadio.Selected.Value,"Parent Only",SortByColumns(Filter('[dbo].[vwGroups]', User().FullName = Broker, ParentGroupID=Blank(), StartsWith(Name,SearchBoxInput_1.Text)),"Name"),"Child Only",SortByColumns(Filter('[dbo].[vwGroups]', User().FullName = Broker, ParentGroupID<>Blank(), StartsWith(Name,SearchBoxInput_1.Text)),"Name"),"All",SortByColumns(Filter('[dbo].[vwGroups]', User().FullName = Broker, StartsWith(Name,SearchBoxInput_1.Text)),"Name"))

     

    The delegation warning is only underlining the red highlighted text above. Do i need to use something different than the = sign?

  • RezaDorrani Profile Picture
    12,145 on at

    Hi @SeanTambling 

     

    Easy

     

    On App OnStart set a variable

     

    Set(varUserEmail,User().FullName)

     

    Then just replace User().FullName with varUserEmail in the formula

     

    --------------------------------------------------------------------------------
    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

     

     

  • SeanTambling Profile Picture
    176 on at

    @RezaDorrani wrote:

    Hi @SeanTambling 

     

    Easy

     

    On App OnStart set a variable

     

    Set(varUserEmail,User().FullName)

     

    Then just replace User().FullName with varUserEmail in the formula

     

    --------------------------------------------------------------------------------
    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

     

     


    In principle, I believe that should work. When i copied and pasted that in app start, I received no errors. When i replaced 

    User().FullName with varUserEmail in the formula, the gallery refreshed and then I saw the entire database. When Iadded a label and just put in the varUserEmail as the only thing in the lable, the label is blank. I tried changing the name of the variable and adding ".Text" to the end of it and ".Value" to the end of it, but nothing worked. I think this should work, but for some reason it is not. When i add a label and just add "User().FullName" (without the quotes ;D) to the label, the users full name is displayed in it. What am i doing wrong?

  • RezaDorrani Profile Picture
    12,145 on at

    Hi @SeanTambling 

     

    When you add it to App on Start inorder for it to have a value you have to run the App On Start (in edit mode of App)

     

    Capture.PNG

     

    Right click on App node and run the on start function

     

    this should ensure your variable has the value

     

    --------------------------------------------------------------------------------
    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

  • SeanTambling Profile Picture
    176 on at

    Thank you, that worked. I had tried to run the app from the start screen, expecting that to make it work, but it didn't. I don't know why. Right clicking the app icon in the edit screen and selecting run, worked. Thank you again.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard