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 / Filtering a gallery by...
Power Apps
Answered

Filtering a gallery by a choice field in a collection

(2) ShareShare
ReportReport
Posted on by 65
Hi all,
 
I have a gallery that is pulling a collection of data (from a SharePoint list).
 
I am trying to filter the data based on status via a check box.
 
Check box default & OnCheck property is as follows:
 
Set(
    showRequestStatusUser,
    Filter(
        Collection,
        Status.Value <> "Complete"
    )
)
The UnCheck property is: 
 
Set(
    showRequestStatusUser,
    Filter(
        Collection,
        Status.Value = "Complete"
    )
)
On the items property of my gallery I have the following filters (keeping in mind I have a text input search bar, and a year drop down, and a further user logged in checkbox) to refine the data, all of which is currently firing as expected:
 
Filter(
    Collection,
    (TextInput.Text in 'Document Code' Or 
    (TextInput.Text in 'Document Name' Or 
    TextInput.Text in ID) || IsBlank(TextInput.Text)),
    Requestor.DisplayName = showUserValidation || IsBlank(showUserValidation),
    (Len(DropdownYear.Selected.Value) = 0 || ReportingYear = DropdownYear.Selected.Value)
)
I have tried to add the following line into the above filter
 
Status.Value = showRequestStatusUser || IsBlank(showRequestStatusUser),
However, I am running into the old "data incompatible table, text" issue. I have tried a few things, but I am stumped. Can anyone help me fix the code?
 
Thanks,
 
DW
 
Categories:
I have the same question (0)
  • LessCodePaths Profile Picture
    100 on at
    If I understand correctly, you would like to add 
    Status.Value = showRequestStatusUser || IsBlank(showRequestStatusUser)
    as the next if statement to the filter.
     
    Based on formulas defined on the top showRequestStatusUser is a table, so u can't compare it with column Status.Value which is text.

    It might become
    Status.Value in showRequestStatusUser.Status || IsBlank(showRequestStatusUser),
    where showRequestStatusUser.Status is column corresponding to the text column containing Status value.
    I'm not exactly sure, because I don't know structure of the Collection.
    I don't understand why Collection is in all the statements. Is it the came datasource?
     
    If yes, I thing it could be rewritten as
    (Status.Value<>"Complete" && CheckBox.Value) || (Status.Value="Complete" && !CheckBox.Value)
     
  • WarrenBelz Profile Picture
    155,929 Most Valuable Professional on at
    Hi DMSC 
    Your issue is that showRequestStatusUser is a Table and you are trying to compare a Text string with it. You also need the field name in the Table you are wanting to compare so
    Status.Value in showRequestStatusUser.YourFieldName || 
    IsBlank(showRequestStatusUser)
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     
  • IAmIntractable Profile Picture
    280 on at
    This might help. I made explicit all the ands and ors:
    
    Filter(
        Collection,
        (
            TextInput.Text in 'Document Code' Or 
            TextInput.Text in 'Document Name' Or 
            Value(TextInput.Text) = ID Or 
            IsBlank(TextInput.Text)
        ) And
        (
            Requestor.DisplayName = showUserValidation Or
            IsBlank(showUserValidation)
        ) And
        (
            Len(DropdownYear.Selected.Value) = 0 Or
             ReportingYear = DropdownYear.Selected.Value
        )
    )
    
    ID is a number.
  • DMSC Profile Picture
    65 on at
    Thanks WarrenBelz 
     
    I tried your solution, however, the .Value in the first part of the code is still throwing the same error ("can't convert data type, can't convert this text to record")
     
    Status.Value in showRequestStatusUser.Status || 
    IsBlank(showRequestStatusUser)
     
    DW
  • Verified answer
    DMSC Profile Picture
    65 on at
     
    This worked perfectly, thank you!!
     
    And to answer your question, the collection is the datasource (trying to keep the app running as fast as possible).
     
    Thanks again.
     
    DW
  • WarrenBelz Profile Picture
    155,929 Most Valuable Professional on at
    I cannot see your data and can only be guided by the extent of the information you post  Value suggests a choice or lookup column - it is obviously text 
  • LessCodePaths Profile Picture
    100 on at
    DMSC
    I'm glad it helped you to resolve the issue.
    Could you mark my reply as solution?
    I would make my day better :)
     
    P.S. be aware of delegation...
     
    L.

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

#2
11manish Profile Picture

11manish 234

#3
Valantis Profile Picture

Valantis 187

Last 30 days Overall leaderboard