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

Sort, Search and Filter

Hi guys,

 

I know sort comes before filter but I have the below depending on the user which branch they select and which due month and the below works perfectly, however, the sorting button is not working and I tried to insert 'Sort' before and after 'Search' and I got errors.

Search(
If('CMB-Branch'.Selected.Result = "All" And 'CMB-DueMonth'.Selected.Result = "All",Stock,
'CMB-Branch'.Selected.Result = "All" And 'CMB-DueMonth'.Selected.Result <> "All",
Filter(Stock,DueMonth = 'CMB-DueMonth'.Selected.Result),
'CMB-Branch'.Selected.Result <> "All" And 'CMB-DueMonth'.Selected.Result = "All",
Filter(Stock, Branch = 'CMB-Branch'.Selected.Result
),
'CMB-Branch'.Selected.Result <> "All" And 'CMB-DueMonth'.Selected.Result <> "All",
Filter(Stock, Branch = 'CMB-Branch'.Selected.Result And DueMonth = 'CMB-DueMonth'.Selected.Result))
,'TXT-Search'.Text, "PartName", "MFGCode","Completed")

 

Thanks in advance.

 

Regards

Wessam

1 REPLY 1
Drrickryp
Super User
Super User

Hi @Samo2005 

I have no idea what your formula does but I am assuming it produces a table.  

 

With({tabl:
 Search(
   If('CMB-Branch'.Selected.Result = "All" And 'CMB-DueMonth'.Selected.Result = "All",
    Stock,
      'CMB-Branch'.Selected.Result = "All" And 'CMB-DueMonth'.Selected.Result <> "All",
    Filter(Stock,DueMonth = 'CMB-DueMonth'.Selected.Result),
      'CMB-Branch'.Selected.Result <> "All" And 'CMB-DueMonth'.Selected.Result = "All",
    Filter(Stock, Branch = 'CMB-Branch'.Selected.Result),
      'CMB-Branch'.Selected.Result <> "All" And 'CMB-DueMonth'.Selected.Result <> "All",
    Filter(Stock, Branch = 'CMB-Branch'.Selected.Result And DueMonth = 'CMB-DueMonth'.Selected.Result)
   ),
        'TXT-Search'.Text, "PartName", "MFGCode","Completed"
 )},
    Sort(tabl, somecolumn, Ascending
    )
)

 

This should be the Items property of a gallery that shows your data sorted on one of the columns in the table that results from your searched If() function.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

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