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 / Filter Gallery depends...
Power Apps
Answered

Filter Gallery depends on Toggle value

(0) ShareShare
ReportReport
Posted on by 85

Dear PowerApps Experts,

 

I need your help - I want to Filter a Gallery with dependency on Toggle value. I have 3 columns:

Expert Name (Person)

Specialization (Single Line of Text)

Hobby (Single Line of Text)

 

The list is filled with data about Expert and his Specializations and/or Hobby. Not every Expert has Hobby/Specialization value. Toggle value is "Specialization" - as false and "Hobby" - as true in toggle (Toggle1.Value).

 

I want to Filter a Gallery depending on toggle, that shows every Expert with Specialization (if he has this column filled), when I toggle to Hobby, it shows every Expertwith Hobby - if he has this column filled. Of couse most of Expert has both columns filled, so they should appear in both views.

 

My Items in Gallery looks like this - it worked only for Specialization, but I need to add this Hobby column and show it properly:

 

 

SortByColumns(
Filter(
AddColumns(
'Champions',
"PersonSort",
Last(ForAll(Split('Expert Name'.DisplayName," "), {Result: ThisRecord.Value})).Result
),
Active, TextSearchBox1.Text in Specialization || TextSearchBox1.Text in 'Expert Name'.DisplayName),
"PersonSort",
If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
)

 


Thank you in advance for your help!


@RandyHayes 

 

Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @KarCz - To filter the Gallery to display non-blank entries in the Specialization field, or non-blank entries in the Hobby field based on a Toggle, consider using an IF or Switch function. e.g:

     

     

    SortByColumns(
     Filter(
     AddColumns(
     'Champions',
     "PersonSort",
     Last(
     ForAll(
     Split(
     'Expert Name'.DisplayName,
     " "
     ),
     {Result: ThisRecord.Value}
     )
     ).Result
     ),
     Active,
     TextSearchBox1.Text in Specialization || TextSearchBox1.Text in 'Expert Name'.DisplayName,
     If(
     Toggle1.Value,
     !IsBlank(Specialization ),
     !IsBlank(Hobby )
     )
     ),
     "PersonSort",
     If(
     SortDescending1,
     SortOrder.Descending,
     SortOrder.Ascending
     )
    )

     

     

    Note I am not clear on what the field type for "Active" is, but I would guess it is a Yes/No field type, which in SharePoint would output true or false.

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Imran-Ami Khan

  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @KarCz ,

     

    Hope this might help:

    //Items property of Gallery
    If(
     Toggle1.Value,
     //Sort and Filter by Hobby
     ,
     //Sort and Filter by Specialization
    )
    
    
    //TrueText of Toggle control
    "Filtered by Hobby"
    
    //FalseText of Toggle control
    "Filtered by Specialization"
  • Verified answer
    WarrenBelz Profile Picture
    156,033 Most Valuable Professional on at

    Hi @KarCz ,

    I may be interpreting what you are asking incorrectly, but is this what you are after ?

    SortByColumns(
     Filter(
     AddColumns(
     'Champions',
     "PersonSort",
     Last(
     Split(
     'Expert Name'.DisplayName,
     " "
     )
     ).Value
     ),
     Active &&
     (
     TextSearchBox1.Text in 'Expert Name'.DisplayName ||
     (
     !Toggle1.Value && 
     TextSearchBox1.Text in Specialization
     ) || 
     (
     Toggle1.Value && 
     TextSearchBox1.Text in Hobby
     ) 
     )
     ),
     "PersonSort",
     If(
     SortDescending1, 
     SortOrder.Descending, 
     SortOrder.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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • KarCz Profile Picture
    85 on at

    Thank you guys, will check that slightly later & let you know. I really appreciate your help!

  • KarCz Profile Picture
    85 on at

    It worked! Thanks!

     

    I just deleted one line to meet my requirements 🙂

     

    SortByColumns(
    Filter(
    AddColumns(
    'Champions',
    "PersonSort",
    Last(
    Split(
    'Expert Name'.DisplayName,
    " "
    )
    ).Value
    ),
    Active &&
    (
    TextSearchBox1.Text in 'Expert Name'.DisplayName ||
    (
    !Toggle1.Value &&
    TextSearchBox1.Text in Specialization
    ) ||
    (
    Toggle1.Value &&
    TextSearchBox1.Text in Hobby
    )
    )
    ),
    "PersonSort",
    If(
    SortDescending1,
    SortOrder.Descending,
    SortOrder.Ascending
    )
    )

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

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard