cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AdamH
Post Partisan
Post Partisan

Using a Gallery as a filter for Switch & Choice Fields

Hi All, 

I have a gallery that I am using as a 'Filter Buttons' for my main gallery which was setup to filter records depending if a switch was on or off within a persons record.

 

I need to change this to incorporate some choice fields that are within the records. As an example:

Choice Fields from a dropdown field:

- Group1

- Group2

- Group3

Code I was using for far is:

With(
    {WMST: 'NC MST Tracker'}, Sort(
    Filter(
        WMST,
        Or(IsBlank(TextInput1.Text),
        TextInput1.Text in 'Employee Name',
        StartsWith(
            'Employee Name',
            TextInput1.Text
        )) && Switch(
            Gallery1_1.Selected.Value,
            "Mentor",
            Mentor,
            "AET",
            'AET Instructor',
            "MST",
            'MST Assessor',
            true
        )
    ),'Employee Name',If(Sort, Descending,Ascending))
)

Anyone able to advise me with this?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi @AdamH ,

As per your copied post below - something like this

With(
   {WMST: 'NC MST Tracker'}, 
   Sort(
      Filter(
         WMST,
         (
            Len(TextInput1.Text) = 0 ||
            TextInput1.Text in 'Employee Name'
         ) && 
         Grade.Value = Gallery1_1.Selected.Value &&
         (!YourAETToggleName.Value || 'AET Instructor') ||
         (!YourMentorToggleNam.Value || Mentor) ||
         (!YourMSTAssessorToggleName.Value || 'MST Assessor') ||
         (!YourPracticeEducatorToggleName.Value || 'Practice Educator')
      ),
      'Employee Name',
      If(
         Sort, 
         Descending,
         Ascending
      )
   )
)

 

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.

Visit my blog Practical Power Apps

 

 

View solution in original post

19 REPLIES 19
WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi @AdamH ,

A couple of things - what are you trying to do with the Switch statement

Switch(
   Gallery1_1.Selected.Value,
   "Mentor",
   Mentor,
   "AET",
   'AET Instructor',
   "MST",
   'MST Assessor',
   true
)

You have not specified which field you are filtering, so that bit does nothing presently.

This part

Or(
   IsBlank(TextInput1.Text),
   TextInput1.Text in 'Employee Name',
   StartsWith(
      'Employee Name',
      TextInput1.Text
   )
) 

if you use the second one, you do not need the third, however if you are happy with StartsWith() and not in, the filter becomes Delegable and you do not need the With() statement (which only takes away the warning - it still only works on the first 2,000 items)

Can you please explain a bit more what you are doing with the Choice fields

 

AdamH
Post Partisan
Post Partisan

@WarrenBelz 

Regarding the switch statement: 

With(
    {WMST: 'NC MST Tracker'}, Sort(
    Filter(
        WMST,
        Or(IsBlank(TextInput1.Text), // SEARCH BAR
        TextInput1.Text in 'Employee Name',
        StartsWith(
            'Employee Name',
            TextInput1.Text
        )) && Switch(
            Gallery1.Selected.Value,
            "Mentor",
            Mentor,
            "AET",
            'AET Instructor',
            "MST",
            'MST Assessor',
            true
        )
    ),'Employee Name',If(Sort, Descending,Ascending))
)

This is the [items] property of my main gallery [browsegallery1] on my [BrowseScreen1] that shows all the staff records. At the top of the screen, there is another gallery [Gallery1] which I've formatted to look like and act as buttons. 

2021-11-13 14_54_45-Window.png

(i think you helped me with this before...)

Within each staff record, I have toggle true/false switches - Example, My record will have MST switched to true, therefor on [BrowseScreen1] which is my main screen, if press 'MST' it will filter all the records with 'MST' toggle switch set to true. So the [Items] property of [Gallery1] is: ["All","Mentor","AET","MST"]

 

What I want to do is expand [Gallery1] and have this filter a LIST field and Combobox on my app as well as the existing toggle fields. 

2021-11-13 16_14_32-Window.png

2021-11-13 16_15_16-Window.png

WarrenBelz
Most Valuable Professional
Most Valuable Professional

Thanks @AdamH ,

I remember the code now, but you had it in amongst the filter rather than the sort (which you had further down). Please look at the below for suggested structure

With(
   {WMST: 'NC MST Tracker'}, 
   Sort(
      Filter(
         WMST,
         (
            Len(TextInput1.Text) = 0 || 
            TextInput1.Text in 'Employee Name'
         ) && 
         StartsWith(
            'Employee Name',
             TextInput1.Text
         ) &&
         (
            Len(YourGradeDD.Selected.Value) = 0  ||
            Grade = YourGradeDD.Selected.Value
         )
      ),
      Switch(
         Gallery1.Selected.Value,
         "Mentor",
         Mentor,
         "AET",
         'AET Instructor',
         "MST",
         'MST Assessor',
         'Employee Name'
      ),
      If(
         Sort, 
         Descending,
         Ascending
      )
   ) 
)

 

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.

Visit my blog Practical Power Apps

 

Hi @WarrenBelz 

 

Yes I thought it was yourself that may have helped with this previously. 

 

Looking at your code, so if I wanted apply those principles in my [Gallery1], where would I insert the additional items? Basically, I make new buttons on my [Gallery1] which filter the grade

Example...

2021-11-13 14_54_45-Window.png

 

Would it be something like?

Len(YourGradeDD.Selected.Value) = 0  ||
            Grade = Grade1.Selected.Value ||
            Grade = Grade2.Selected.Value ||
            Grade = Grade3.Selected.Value ||

 

WarrenBelz
Most Valuable Professional
Most Valuable Professional

@AdamH ,

Is this a new gallery ? Gallery 1 is sorting, not filtering.

If you have a new gallery (Gallery2) for those controls with the Items

[
   "Grade 1",
   "Grade 2",
   "Grade 3",
   "Grade 4"
]

it would be something like this

With(
   {WMST: 'NC MST Tracker'}, 
   Sort(
      Filter(
         WMST,
         (
            Len(TextInput1.Text) = 0 || 
            TextInput1.Text in 'Employee Name'
         ) && 
         StartsWith(
            'Employee Name',
             TextInput1.Text
         ) &&
         Grade = Gallery2.Selected.Value
      ),
      Switch(
         Gallery1.Selected.Value,
         "Mentor",
         Mentor,
         "AET",
         'AET Instructor',
         "MST",
         'MST Assessor',
         'Employee Name'
      ),
      If(
         Sort, 
         Descending,
         Ascending
      )
   ) 
)

 

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.

Visit my blog Practical Power Apps

 

@WarrenBelz 

Sorry for the late reply on this, I was unwell with a chest infection and have only come back to the world of the living.

 

This is not with a new gallery, I have just added to the [ITEMS] of the existing Gallery1 - sorry for the confusion between sorting and filtering which has made you think I've added a new gallery - I'll be careful with my choice of words next time.

 

Gallery1 is sorting and I wanted to add the ability to sort with the switch statement (toggle switches for Mentor, AET & MST

 

and

 

also the grade field (LIST) Grade 1, Grade 2 and Grade 3. 

 

 

AdamH
Post Partisan
Post Partisan

Hi @WarrenBelz 

I've had some time to review your code and I do manage to get the grade [LIST] sort to work, but the switch sort has stopped working. I noticed that the true is missing from the end of the switch section:

 'MST Assessor',
            true
        )
    ),'Employee Name',If(Sort, Descending,Ascending))

I tried to re-insert the 'Employee Name' true), with your version and I cannot get it to work. 

app buttons.pngapp buttons1.png

WarrenBelz
Most Valuable Professional
Most Valuable Professional

@AdamH ,

How are you determining the Grade sort and how does that mix with the gallery determined sort at the bottom?

WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi @AdamH ,

I cannot test it presently, but the Switch code should work on the basis that 'Employee Name' should apply if none of the others are chosen. You could go back to

If(
   Gallery1.Selected.Value = "Mentor",
   Mentor,
   Gallery1.Selected.Value = "AET",
   'AET Instructor',
   Gallery1.Selected.Value = "MST",
   'MST Assessor',
   'Employee Name'
)

but it is the same thing

Helpful resources

Announcements

Tuesday Tip | How to Get Community Support

It's time for another Tuesday Tip, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.       This Week: All About Community Support Whether you're a seasoned community veteran or just getting started, you may need a bit of help from time to time! If you need to share feedback with the Community Engagement team about the community or are looking for ways we can assist you with user groups, events, or something else, Community Support is the place to start.   Community Support is part of every one of our communities, accessible to all our community members.   Within each community's Community Support page, you'll find three distinct areas, each with a different focus to help you when you need support from us most. Power Apps: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pa_community_support Power Automate: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpa_community_support Power Pages: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpp_community_support Copilot Studio: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pva_community-support   Community Support Form If you need more assistance, you can reach out to the Community Team via the Community support form. Choose the type of support you require and fill in the form accordingly. We will respond to you promptly.    Thank you for being an active part of our community. Your contributions make a difference!   Best Regards, The Community Management Team

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

Top Solution Authors
Top Kudoed Authors
Users online (4,986)