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 / Creating a filter with...
Power Apps
Answered

Creating a filter with a choice column

(1) ShareShare
ReportReport
Posted on by 225

I have a filter on a text input control that works great thanks to a tip off from @ANB

However, I can't get a filter working for a choice column.

 

I've tried a few different syntaxes and maybe the closest one is:

 

Search(AddColumns(colContProcessing, "Activity", cn_activitytype.Value), TxtInpActivityType_EP, "Activity")

But if I hover over the colContProcessing, which is a collection,  I get two messages "The function 'AddColumns' has some invalid arguments" and "The function 'Search' has some invalid arguments".

 

I can't get any closer than this...any ideas anyone?  I know choices need to be converted in text columns before you can search, which is what I'm trying to do here.  Thanks! 

Categories:
  • M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @Automate2create 

    Try This  Formula

    Filter(
     AddColumns(
     colContProcessing,
     "ActivityText", cn_activitytype.Value
     ),
     StartsWith(ActivityText, TxtInpActivityType_EP.Text)
    )

    Please accept this solution if it resolves the issue.
    Best regards,
    Muhammad Ali

  • Chocolate_Pizza Profile Picture
    225 on at

    Thanks for looking at this but no, it is still erroring and complaining about invalid arguments 😮

  • M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @Automate2create 

    Try the Formula like This

    SortByColumns(
     If(
     Dropdown.Selected.Value = "All",
     Search(
     SPlist,
     Searchbox.Text,
     "Firstname", 
     "Surname"
     ),
     Filter(
     SPlist,
     YourChoiceColumnName.Value = Dropdown.Selected.Value
     )
     ),
     "Firstname", 
     If(SortDescending1, Descending, Ascending)
    )

    Please accept this solution if it resolves the issue.
    Best regards,
    Muhammad Ali

  • Chocolate_Pizza Profile Picture
    225 on at

    Thanks, I tried the formula and substituted the field names etc but I am still getting this error:

    "Activity" = There is an error in this formula.

     

    Here is how I substituted the fields so you can check that I've done what is intended.

    SortByColumns(
                   If(
                         CboStatus_EP.Selected.Value = "All",
                         Search(
                               colContProcessing,
                               TxtInpActivityType_EP.Text,
                               "Activity",
                         ),
                         Filter(
                                 colContProcessing,
                                 CboStatus_EP.Value = CboStatus_EP.Selected.Value
                          )
                  ),
                  "Activity"
             )

     

  • M_Ali_SZ365 Profile Picture
    1,110 on at

    @Automate2create 

    First, we need to create a text representation of your choice column in the collection:

    Collect(colWithTextActivities, AddColumns(colContProcessing, "ActivityText", cn_activitytype.Value));

    Then, depending on whether you want all items or just ones matching your search, use this text column:

    Set(
     filteredCollection,
     If(
     CboStatus_EP.Selected.Value = "All",
     Search(
     colWithTextActivities, 
     TxtInpActivityType_EP.Text,
     "ActivityText"
     ),
     Filter(
     colWithTextActivities,
     ActivityText = CboStatus_EP.Selected.Text
     )
     )
    );

    Make sure the cn_activitytype.Value actually points to the text value of your choice column. Replace CboStatus_EP.Selected.Text with the appropriate property if Text isn't correct. TxtInpActivityType_EP.Text should be the ID of your text input.

    Give this a try and let me know if it helps! If it still throws an error, could you share more about the colContProcessing structure and the choice field details? It’ll help in nailing down the exact issue.

    Please accept this solution if it resolves the issue.
    Best regards,
    Muhammad Ali

  • Chocolate_Pizza Profile Picture
    225 on at

    It's not working but really appreciate your help on this.  Also just to confirm as I didn't specify this but I am trying to do this on the Items property of the gallery.  Now I am getting an interesting message:

    "Behaviour function in a non behaviour property.  You can't use this property to change values elsewhere in the app."

    The colContProcessing is a collection that populates the gallery with some fields from the ContainerActivities table (Dataverse).  It is created on a screen called scrEntryProcessing.  The purpose of the screen for the user is to do some work in our company system based off each row in the app and then mark each line as completed in the app.  The user needs to be able to filter on the ActivityType as they will find it easier to look at similar activity types together.

     

    Here is the ClearCollect code for the creation of colContProcessing.

     

    //Create Collection
    ClearCollect(colContProcessing, SortByColumns(ShowColumns(ContainerActivities, "cn_agentlocode", "cn_container", "crae5_iso", "cn_fullempty", "crae5_voyage", "cn_pol", "cn_pod", "cn_activitytype", "cn_activitydatetime", "crae5_status", "cn_comments", "cn_inputdatetime"),"crae5_voyage", SortOrder.Descending));

    //filter for Collection
    ClearCollect(colContProcessing, Filter(colContProcessing, cn_inputdatetime > DateAdd(Now(),-90,TimeUnit.Days)));

     

     

     

  • STS1SS Profile Picture
    307 on at

    Reference the VALUE of the choice column, not the TEXT.

     

    So go look at the design and reference the numeric value and not that text.

  • Verified answer
    Chocolate_Pizza Profile Picture
    225 on at

    I managed to solve it in the end, my original syntax was almost there but I needed to put Text(cn_activitytype) instead of just cn_activitytype.  So close....yet so far...

    Thanks everyone for your help

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard