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 / Sort, Filter, Search S...
Power Apps
Answered

Sort, Filter, Search Syntax

(0) ShareShare
ReportReport
Posted on by

Hello,

 

@mdevaney  Matthew Devaney wrote a terrific blog post on sorting columns that I am trying to implement for 3 text columns in my app. I'm having trouble incorporating it into my existing Gallery Items formula and was wondering if I could get a little help nailing down the proper syntax. 

 

I've attached screenshots of the "before" formula that works, my broken attempt to incorporate Matthew's Switch formula and a color-coded version of how I'm trying to make sense of what goes where when you are trying to Sort, SortbyColumns, Search and Filter a gallery all at once.

 

Matthew's solution is exactly what I was looking for as I couldn't figure out how to make the chevron's go up and down independently so I would love to figure this out. Thanks in advance for your help. Sometimes I feel like I am never going to get all the PowerApps intricacies down, but it's so cool I have to keep trying.

 

Regards,

Teresa

BrokenSyntax.png
WorkingFormula.png
Color-CodedVersion.png
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,346 Most Valuable Professional on at

    Hi @tagustin2020 ,

    Please post any code also as Text as it helps correct it.

    You are using a table value at the top of the Switch statement and then text values as criteria, so this will not work.

    When you post the text, can you please explain what you are trying to do.

  • mdevaney Profile Picture
    29,991 Moderator on at

    @tagustin2020 
    Can you please post your current code inside the forums?  That way I can do an experiment without having to re-write anything.

    Screenshots are great... and I wish more people did screenshots!  In this case having the code in text format would be handy too.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • WarrenBelz Profile Picture
    155,346 Most Valuable Professional on at

    @tagustin2020 

    @mdevaney posted a couple of seconds after me - I will leave you with him.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @tagustin2020 

    It looks like you are just trying to sort by different columns based on the value of locSortColumn.

    It also appears that the text value in that variable is the same as the column name, so you should just be able to go with this:

    SortByColumns(
     Filter('Tool Design Support Requests',
     StartsWith('Request Summary Title', TxtSearchBox.Text) &&
     (ddStatus.Selected.Value = "Status All" || 'Request Status'.Value = ddStatus.Selected.Value),
     
     locSortColumn,
     If(locSortAscending, Ascending, Descending)
    )

     

    A lot of good minds on this one for you, so hopefully this is helpful.

     

  • tagustin2020 Profile Picture
    on at

    Hi Matthew,

     

    Here is the BEFORE formula that is verified to be working (doesn't include your Switch/Sort formula syntax yet):

     

    SortByColumns(

            Filter(

                'Tool Design Support Requests',

                StartsWith(

                    'Request Summary Title',

                    TxtSearchBox.Text

                ) && (ddStatus.Selected.Value = "Status All" || 'Request Status'.Value = ddStatus.Selected.Value)

            ),

        "Title",

        Ascending

    )

     

    Here is what I tried to do. It threw something like 60 errors so epic fail - lol.

     

    SortByColumns(

    Switch(

            Filter(

                'Tool Design Support Requests',

                StartsWith(

                    'Request Summary Title',

                    TxtSearchBox.Text

                ) && (ddStatus.Selected.Value = "Status All" || 'Request Status'.Value = ddStatus.Selected.Value)

            ),

    locSortColumn,

    ”NeededBy”, Sort(‘Tool Design Support Requests’, NeededBy, If(locSortAscending, Ascending,Descending)),

    ”Title”, Sort(‘Tool Design Support Requests’, Title, If(locSortAscending, Ascending,Descending)),

    ”ProjectNumber”, Sort(‘Tool Design Support Requests’, ProjectNumber, If(locSortAscending, Ascending,Descending)),

    ‘Tool Design Support Requests’)

        "Title",

        Ascending

    )

     

    I don't know how to put formulas into light gray boxes in these forum postings. Can you educate me on how to do that?

     

    Thanks,

    Teresa

  • tagustin2020 Profile Picture
    on at

    Thanks for the suggestion Randy. I appreciate you pitching in! Let's see what Matthew comes back with as well on this one since I'm basing the effort on his post. Kind regards, Teresa

  • mdevaney Profile Picture
    29,991 Moderator on at

    @tagustin2020 

    Perfect.  I will respond in a few hours once I’m back at the computer.  Thank you so much for providing the code and I’m super excited you want to implement the sorting controls!

  • tagustin2020 Profile Picture
    on at

    Thank you Matthew. I really appreciate your help and all of your blog posts. I find them very interesting and helpful. I just used a portion of your data validation blog for a date picker in my new request form today. Please keep those great ideas coming. I really like the clever solutions and attractive designs you come up with.

     

    Kind regards,

    Teresa

  • askondo Profile Picture
    Microsoft Employee on at

    @mdevaney @RandyHayes @WarrenBelz 

    Thank you for your responses to the forum. Your answers keep the forum active. Thank you for your continued support.

  • mdevaney Profile Picture
    29,991 Moderator on at

    @tagustin2020 
    OK, I'm back at a computer now.  From what I understand reading your post this code is currently working. 

    Filter(
     'Tool Design Support Requests',
     StartsWith('Request Summary Title', TxtSearchBox.Text)
     && (ddStatus.Selected.Value = "Status All"
     || 'Request Status'.Value = ddStatus.Selected.Value)
    )

     

    Here's how I would use your FILTER function inside the SWITCH statement.

    Switch(
     locSortColumn,
     ”NeededBy”,
     Sort(
     Filter(
     'Tool Design Support Requests',
     StartsWith('Request Summary Title', TxtSearchBox.Text)
     && (ddStatus.Selected.Value = "Status All"
     || 'Request Status'.Value = ddStatus.Selected.Value)
     ),
     NeededBy, 
     If(locSortAscending, Ascending,Descending)
     ),
     ”Title”,
     Sort(
     Filter(
     'Tool Design Support Requests',
     StartsWith('Request Summary Title', TxtSearchBox.Text)
     && (ddStatus.Selected.Value = "Status All"
     || 'Request Status'.Value = ddStatus.Selected.Value)
     ),
     Title, 
     If(locSortAscending, Ascending,Descending)
     ),
     ”ProjectNumber”,
     Sort(
     Filter(
     'Tool Design Support Requests',
     StartsWith('Request Summary Title', TxtSearchBox.Text)
     && (ddStatus.Selected.Value = "Status All"
     || 'Request Status'.Value = ddStatus.Selected.Value)
     ),
     ProjectNumber, 
     If(locSortAscending, Ascending,Descending)
     ),
     "Title"
     Sort(
     Filter(
     'Tool Design Support Requests',
     StartsWith('Request Summary Title', TxtSearchBox.Text)
     && (ddStatus.Selected.Value = "Status All"
     || 'Request Status'.Value = ddStatus.Selected.Value)
     ),
     Title, 
     If(locSortAscending, Ascending,Descending)
     )
    )

     


    Let me know if you encounter errors 🙂

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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 915

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 457

Last 30 days Overall leaderboard