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 / Power gallery Filterin...
Power Apps
Answered

Power gallery Filtering Based On Option Set value

(0) ShareShare
ReportReport
Posted on by 110

Hello all need help with below,
I have a gallery (Gallery3) on Screen1, whose Items property is set to
SegmentCollection. The collection is populated using the following formula:

ClearCollect( SegmentCollection, { SegmentName: "All Segment" }, { SegmentName: "Segment 1" }, { SegmentName: "Segment 2" }, { SegmentName: "Segment 3 }, { SegmentName: "Segment 4" } );

On Screen2, I have another gallery (Gallery2_11). The Items property of this gallery is set to the 'Segments' table, which contains a choice column named 'Supporting Segment'. I want to filter Gallery2_11 based on the 'Supporting Segment' selected in Power Apps.

'Supporting Segment' have, Segment 1, Segment 2, Segment 3, and Segment 4 as choices and All segment is not there in choices, but if user select All segment Then gallery will show All records.
and choice is coming from Choices(Segment) in Dataverse

Filter(
Segments,
'Supporting Segment'= Gallery3.Selected.SegmentName
)

when i am filtering on that i am facing error of Incompatible type of comparison , these types cant be compared, table text.
@ShaheerAhmad @WarrenBelz @LaurensM @mmbr1606 @SpongYe 

image.png
I have the same question (0)
  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

     

    You can try this:

    Filter(

        Collprospects,

        'Supporting Segment'.Value = Gallery3.Selected.SegmentName

    )

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

    Hey @faruk1 

  • faruk1 Profile Picture
    110 on at

    faruk1_0-1710097785896.pngfaruk1_1-1710097819235.png

    facing same issue with above formula as well

  • faruk1 Profile Picture
    110 on at

    faruk1_0-1710098999077.png

    i am sharing more information about column type and choices

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @faruk1,

     

    The current error occurs due to the selected gallery item not being the same type (record) as your column (table). Additionally, the collection will not match the expected record schema of your choice set.

     

    In order to solve the issue, we will have to (1) map the selected gallery record with the correct choice option to match the Dataverse choice record schema and (2) use the 'in' operator to search whether the currently selected record exists in the multi-select column (table). I recently solved a similar issue here that can provide additional insights - although the column in that post was a single-select choice.

     

    With(
     {
     //Map gallery selection to correct choice value
     //(Solves the record schema issue)
     wChoice: Switch(
     Gallery3.Selected.SegmentName,
     //Adjust choice name / choice value if necessary
     "Segment 1",
     Segment.'Segment 1',
     "Segment 2",
     Segment.'Segment 2',
     "Segment 3",
     Segment.'Segment 3',
     "Segment 4",
     Segment.'Segment 4'
     )
     },
     Filter(
     Segments,
     //Filter based on choice if 'All Segment' is not selected
     //('in' solves the incompatible type issue, table - record)
     Gallery3.Selected.SegmentName = "All Segment" || wChoice in 'Supporting Segment'
     )
    )

    Please note that this approach results in a non-delegable query.

     

    As an optimization: Due to Gallery 3 being on another screen than the current gallery, I would recommend saving the selection to a variable and referencing this in your Filter instead.

    Navigate(Screen2, ScreenTransition.None, {locSelectedSegment: Gallery3.Selected.SegmentName})

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • faruk1 Profile Picture
    110 on at

    thanks @LaurensM , for giving the solution, however it's working for all segments only for other it's not working  for other segments

    faruk1_0-1710104045944.png

     

    however when i added choices to my gallery which has only Segment1,Segment2,Segment3,Segment4 then below code works fine, but what should i do with all segment?
    Filter(
    Prospects,
    Gallery3.Selected.Value in 'Supporting Segment'.Value
    )

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @faruk1,

     

    I unfortunately am unable to recreate that error on my end. Can you confirm that (1) the code does not provide any errors when written in the Items property, (2) all needed segments are correctly defined within the Switch statement?

     

    I hope this helps!

  • faruk1 Profile Picture
    110 on at

    faruk1_0-1710106141861.png

    this is the error message i am facing now.  the code does not provide any errors, but my gallery is not filtering based onthat, sometime same items for all segment 

  • faruk1 Profile Picture
    110 on at

    JSON parsing error, the length of option set values does not match the length of option set labels.

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @faruk1,

     

    The provided code does not seem to throw any errors in my editor. Although I am not a fan of using If statements within the items property - would it be possible to try the code below to see whether splitting the choice & all segment logic affects the errors?

     

    If(
     Gallery3.Selected.SegmentName = "All Segment",
     //Apply no filter when all segments is selected
     Segments,
     With(
     {
     //Map gallery selection to correct choice value
     //(Solves the record schema issue)
     wChoice: Switch(
     Gallery3.Selected.SegmentName,
     //Adjust choice name / choice value if necessary
     "Segment 1",
     Segment.'Segment 1',
     "Segment 2",
     Segment.'Segment 2',
     "Segment 3",
     Segment.'Segment 3',
     "Segment 4",
     Segment.'Segment 4'
     )
     },
     Filter(
     Segments,
     //('in' solves the incompatible type issue, table - record)
     wChoice in 'Supporting Segment'
     )
     )
    )

     

    That said, I usually filter by using a combobox on the same screen without adding additional choice options to display all records. By using a combobox we can show no selection by default which acts similar to our 'All Segments' - when the user selects a selection within the combobox then we apply the filter:

     

    //Combobox items property
    Choices(Segment)

     

    //Gallery items property
    Filter(
     Segments,
     !IsBlank(Combobox.Selected) || 'Supporting Segment' = Combobox.Selected
    )

     

    I hope this helps!

  • faruk1 Profile Picture
    110 on at

    Thank You @LaurensM , It's Working perfectly now.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard