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
Thank You @LaurensM , It's Working perfectly now.
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!
JSON parsing error, the length of option set values does not match the length of option set labels.
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
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!
thanks @LaurensM , for giving the solution, however it's working for all segments only for other it's not working for other segments
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
)
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!
i am sharing more information about column type and choices
facing same issue with above formula as well
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
stampcoin
17
ankit_singhal
11
Super User 2025 Season 1
mmbr1606
9
Super User 2025 Season 1