cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bsamms
Frequent Visitor

Sorting a gallery by multiple criteria, default based on first letter of a list field:

The main page of my app has a gallery which lists cases, along with two text search boxes, one for searching the cases by the employee's last name, the second for searching the cases by the employee's ID number.  My current ITEMS script is:

 

SortByColumns(Filter([@CaseTracker_data], StartsWith('Employee Last Name', TextSearchBox1.Text), StartsWith('Employee ID', TextSearchBox2.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

Both search inputs work perfectly, however I'm confused by the (default) result displayed when nothing is searched.  Anytime I attempt to change "Title" I break the script, but I need it to display in descending order all contents in the CaseNumber field of the CaseTracker_data list which start with the letter "A".  Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

 

Try to use a check condition Is blank for the text box in that case by pass the filter conditions  and show all the data else add your code. That should work.

 

Sarath

View solution in original post

5 REPLIES 5
Eelman
Super User
Super User

@bsamms 

Try using OR between your two StartsWith's, ie

 

SortByColumns(
    Filter([@CaseTracker_data], 
        StartsWith('Employee Last Name', TextSearchBox1.Text) ||
        StartsWith('Employee ID', TextSearchBox2.Text)),
    "Title", If(SortDescending1, Descending, Ascending)
)

 

Note: you can also get away with only using one Search Text box if space is limited using the above formula structure. I use this a lot in my phone apps due to space constraints, I just add help info in the HintText property for the user.

KrishnaV
Super User III
Super User III

Hi,

 

I am able to succeed in your scenario by simply using the same query you are using for items for the gallery.

Gallery.png

Please see the below output.

 

Gallery Search.gif

 

 

Let me know if that helps.

 

Regards,

Krishna

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Sorry I know the gif was not seen clear if u want I can provide you a series of images. The only change I did is I applied the formula on Items property.

 

Regards, 

Krishna


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
bsamms
Frequent Visitor

@KrishnaV @Eelman , thank you both for taking the time to assist here.  I may not have addressed my problem very well in the first post:  My search functions are working as needed, I need help understanding the result shown by default, when nothing is searched.

..."Title", If(SortDescending1, Descending, Ascending)) 

 

What is Title?  Assuming it is the Title field of the list, I attempted to change it to a more relevant result (CaseNumber) but get errors.  I need the default (non searchbox) result to show the data from the list's CaseNumber field which begins with the letter "A", in descending order.  Thank you.

Hi,

 

Try to use a check condition Is blank for the text box in that case by pass the filter conditions  and show all the data else add your code. That should work.

 

Sarath

View solution in original post

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,291)