Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
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 

  • faruk1 Profile Picture
    110 on at
    Re: Power gallery Filtering Based On Option Set value

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

  • Verified answer
    LaurensM Profile Picture
    12,510 Super User 2025 Season 1 on at
    Re: Power gallery Filtering Based On Option Set value

    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
    Re: Power gallery Filtering Based On Option Set value

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

  • faruk1 Profile Picture
    110 on at
    Re: Power gallery Filtering Based On Option Set value

    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 

  • LaurensM Profile Picture
    12,510 Super User 2025 Season 1 on at
    Re: Power gallery Filtering Based On Option Set value

    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
    Re: Power gallery Filtering Based On Option Set value

    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,510 Super User 2025 Season 1 on at
    Re: Power gallery Filtering Based On Option Set value

    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
    Re: Power gallery Filtering Based On Option Set value

    faruk1_0-1710098999077.png

    i am sharing more information about column type and choices

  • faruk1 Profile Picture
    110 on at
    Re: Power gallery Filtering Based On Option Set value

    faruk1_0-1710097785896.pngfaruk1_1-1710097819235.png

    facing same issue with above formula as well

  • mmbr1606 Profile Picture
    12,328 Super User 2025 Season 1 on at
    Re: Power gallery Filtering Based On Option Set value

     

    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 

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Microsoft Dataverse

#1
stampcoin Profile Picture

stampcoin 17

#2
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

Overall leaderboard

Featured topics