cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Emptyglasses
Post Prodigy
Post Prodigy

Search Bar

Hi,

 

I'm using a search bar in my Powerapp form, but it is showing some error in the function

Emptyglasses_0-1669979195035.png

SUPD is my sharepoint list name 

Employee Name is the my Tittle coloumn

When the user searches the employee name ,i want the data to be filtered only by showing the names 

 

Could anyone helped me to fix this 

1 ACCEPTED SOLUTION

Accepted Solutions

Switch(vartabselected,
    1,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text)
        ),
        "Title",
        Descending
    )
    ,
    2,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text),
                'Access Details '.Value = "Display"
        ),
        "Title",
        Descending
    )
    ,
    3,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text),
                'Ticket Status '.Value="Created"
        ),
        "Title",
        Descending
    )
    ,
    4,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text),
                (
                    'Approval Status - Reporting Manager '.Value ="Rejected"
                    ||
                    'Approval Status - SPoC'.Value="Rejected"
                    ||
                    'Approval Status - SME '.Value="Rejected"
                    ||
                    'Approval Status - HoD'.Value="Rejected"
                )
        ),
        "Title",
        Descending
    )
)

 

Hopefully the above explains a bit - you can't have two separate statements inside - how will the program know what to include - imagine trying to type two different statements in Excel without anything to join/combine them, it's the same here, we have to define some way they interact

In this case for each of the switch statements, we have a filter that includes the searchbox and the condition that applies to that selected tab for the filter

 

If you have any questions about the code please feel free to ask!

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

7 REPLIES 7
iAm_ManCat
Super User
Super User

Hi @Emptyglasses 

 

You are missing the column to sort by

SortByColumns(Filter(SUPD, StartsWith('Employee Name', TextInput1.Text) ), "created", Descending)
@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Hi, 

Thanks for your response 

I'm, passing two function in my item property , But it is showing some error 

Emptyglasses_0-1669981881036.png

 

Could u please help me to fix it

Can you paste the code please, I'm not going to try re-typing that.

 

You can't use two functions in your items, you need to simplify it into a single item - For each item of vartabselected, we would have the startswith from the first line - if you paste your code here I can help clean it up

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Hi thanks for the repsonse 

I've shared the code with you please look into it 

 

SortByColumns(Filter(SUPD,StartsWith('Employee Name',TextInput1.Text)),"Title",Descending)
Switch(vartabselected,1,SUPD,2,Filter(SUPD,'Access Details '.Value = "Display"),3,Filter(SUPD,'Ticket Status '.Value="Created"),4,Filter(SUPD,Or('Approval Status - Reporting Manager '.Value ="Rejected",'Approval Status - SPoC'.Value="Rejected",'Approval Status - SME '.Value="Rejected",'Approval Status - HoD'.Value="Rejected")))

Switch(vartabselected,
    1,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text)
        ),
        "Title",
        Descending
    )
    ,
    2,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text),
                'Access Details '.Value = "Display"
        ),
        "Title",
        Descending
    )
    ,
    3,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text),
                'Ticket Status '.Value="Created"
        ),
        "Title",
        Descending
    )
    ,
    4,
    SortByColumns(
        Filter(SUPD,
                StartsWith('Employee Name',TextInput1.Text),
                (
                    'Approval Status - Reporting Manager '.Value ="Rejected"
                    ||
                    'Approval Status - SPoC'.Value="Rejected"
                    ||
                    'Approval Status - SME '.Value="Rejected"
                    ||
                    'Approval Status - HoD'.Value="Rejected"
                )
        ),
        "Title",
        Descending
    )
)

 

Hopefully the above explains a bit - you can't have two separate statements inside - how will the program know what to include - imagine trying to type two different statements in Excel without anything to join/combine them, it's the same here, we have to define some way they interact

In this case for each of the switch statements, we have a filter that includes the searchbox and the condition that applies to that selected tab for the filter

 

If you have any questions about the code please feel free to ask!

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Hi, Thanks for your insightful advice ,its worked perfectly fine 

I wonder why we shouldn't pass the code at the beginning as for all rather than passing the sort by columns function on each tab property.

 

I had issues with the variable approach to Sorting in the past so it's a habit now to include the whole sort/filter/condition inside each switch - not sure if that's been fixed but "once burned, twice shy" as they say

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,560)