cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Newbie2019
Resolver I
Resolver I

Two Galleries - Second gallery won't sort by columns filter starts with ....

Hi,

I was wondering if anyone had any suggestions as to why the my sort by columns does not work.

 

Within my app I have two galleries.

 

The first search which works has:

 

SortByColumns(Filter(MIMS, StartsWith(Student(, TextSearchBox1.Text)), "Student", If(SortDescending1, Descending, Ascending))

 

This works. I can enter the first part of a name and it populates all entries under that name.

 

I have made a duplicate of this gallery and the only difference is that I have added a toggle to this page.

 

The search field has the following:

 

SortByColumns(Filter(MIMS, StartsWith(Student(, TextSearchBox1_2.Text)), "Student", If(SortDescending1, Descending, Ascending))

 

Even though I have changed the textsearchbox, it will not perform a search.

 

I would also like to know how to reverse the list so it auto polulates based on date newest to oldest

 

Any suggestions would be appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello!

 

Ok, I see what the problem is - that code needs to go into the Items of the gallery, the textbox requires no code at all as the gallery is doing the filtering by the contents of the textbox!

 

Could you try that for me with the code I suggested and let me know how that goes?

 

Thanks,

Sancho

@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

5 REPLIES 5
iAm_ManCat
Super User II
Super User II

Hiya!

 

It looks like there's an additional open bracket in this formula, could you try removing it?

 

 

SortByColumns(
    Filter(
        MIMS,
        StartsWith(
            Student(, TextSearchBox1_2.Text)
        ),
        "Student", If(SortDescending1, Descending, Ascending)
    )

If you want to sort these by Created Date then use a DateColumn such as Created (if that's the name available in your datasource):

 

 

SortByColumns(
    Filter(
        MIMS,
        StartsWith(
            Student,
TextSearchBox1_2.Text
) ), "Created",
If(SortDescending1, Descending, Ascending) )

Can you confirm that the Second Searchbox is TextSearchBox1_2 as well?

 

Thanks,

Sancho

@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 @iAm_ManCat 

Thank you for your assistance. I seem to still have the same problem. 

 

The first gallery has throws an error when the suggested bracket is removed:

 

brac.JPG

 

When I hover on the red x is states: Expected Text Value

 

If I restore the original formula it works.

 

brac 3.JPG

When I use the same code on the net gallery, but changing for a different text box:

 

brac 2.JPG

 

When I type a first name search, nothing happens....

 

Is it perhaps not possible to have two galleries searching the same sharepoint list?

 

I will try the suggested 'created' feature shortly.

 

Any further suggestions @iAm_ManCat would be appreciated.

 

Cheers.

 

Hello!

 

Ok, I see what the problem is - that code needs to go into the Items of the gallery, the textbox requires no code at all as the gallery is doing the filtering by the contents of the textbox!

 

Could you try that for me with the code I suggested and let me know how that goes?

 

Thanks,

Sancho

@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

Hi @iAm_ManCat 

 

Thank you so much for identifying the problem. I'm an idiot!

 

I have changed the formula to 'created'. I was wondering how I reverse the gallery so the newest entires populate first?

 

Newest  to Oldest based on the 'created' field?

 

Thanks again for your assistance.

Hi @Newbie2019

 

Happy to help - what you've got in your formula is a default way of sorting, which is defined by a variable (that variable is then changed by pressing the sort button within the menu bar)

 

So in your formula,

If(SortDescending1, Descending, Ascending)

Change them around to:

If(SortDescending1, Ascending, Descending)

 

This should reverse the sort order by default, and allow others to still change the direction using the sort button,

 

I hope all of this has helped you, please feel free to Thumbs Up any posts that you feel have contributed 🙂

 

Cheers,

Sancho

@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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (20,758)