cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AndrewJRoberts
Level: Powered On

Filter in a browse screen

Hi

 

I have been following Shane Young's instructions on how to use Multiple Drop Downs to filter (but using a combobox) data and I have hit a block; again. 

 

In a SharePoint list I have two field, both Text Fields "Customer" and "Order Number"

The first stage was to create and test a search using the "Order Number", before moving on to adding a second 

 

  • "Browse Screen 1"
    • OnVisible
      • ClearCollect(Collect3, {Result: "All"}); Collect(Collect3, Distinct(Sales, 'Order Number'))
  • BrowseGallery1
    • Combo Box cmbOrderSearch
      • Collect3
  • Items
    • Filter(Sales, 'Order Number'=cmbOrderSearch.Selected.Result)

When I try to add the "If" statement things stops working for the True (Sales, 'Order Number')

If(cmbOrderSearch.Selected.Result = “All”, Sales, 'Order Number', Filter(Sales, 'Order Number'=cmbOrderSearch.Selected.Result)

Any help would be appreciated 

 

Many Thanks in advance.

BR 

 

Andy

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Level 8

Re: Filter in a browse screen

Hi @AndrewJRoberts ,

OK - if "All" is selected, you want all sales results, but if something else is selected, you want only the results matching the selection. So the Items property of your gallery should be 

If(
   cmbOrderSearch.Selected.Result = “All”, 
   Sales,
   Filter(
      Sales, 
      'Order Number'=cmbOrderSearch.Selected.Result
   )
)

You are saying you are getting all the records - what is the value of cmbOrderSearch.Selected.Result when this is happening? Put a label on the screen and set the Text property to this to check.

 

View solution in original post

13 REPLIES 13
WarrenBelz
Level 8

Re: Filter in a browse screen

Hi @AndrewJRoberts ,

 

Firstly, parsing your code below, you have a bracket missing at the end to close, bit more importantly have an extra argument in your If statement.

If(
   cmbOrderSearch.Selected.Result = “All”
, 
   Sales
, 
   'Order Number'
, 
   Filter(
      Sales, 
      'Order Number'=cmbOrderSearch.Selected.Result
   )

Please let me know if I need to look further.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

AndrewJRoberts
Level: Powered On

Re: Filter in a browse screen

Yes the issue is around the section , Sales, 'Order Number',

Sales is the name of the Sharpoint Table, Order number is the column

 

If I take out the section 'Order Number' it brings up all details of all the Table records, if I take out Sales, it creates an error

 

Andy

WarrenBelz
Level 8

Re: Filter in a browse screen

Hi @AndrewJRoberts ,

OK - if "All" is selected, you want all sales results, but if something else is selected, you want only the results matching the selection. So the Items property of your gallery should be 

If(
   cmbOrderSearch.Selected.Result = “All”, 
   Sales,
   Filter(
      Sales, 
      'Order Number'=cmbOrderSearch.Selected.Result
   )
)

You are saying you are getting all the records - what is the value of cmbOrderSearch.Selected.Result when this is happening? Put a label on the screen and set the Text property to this to check.

 

View solution in original post

AndrewJRoberts
Level: Powered On

Re: Filter in a browse screen

Your latest information worked a treat, Thank you so much.

AndrewJRoberts
Level: Powered On

Re: Filter in a browse screen

I have been off site since my last response and now I am back a request has come in to modify the search filter.
They now need a second search filter to allow them to search either by the Customers name or Order number.
I have started to amend the app so the relating details

 

  • Browse Screen 1
    • OnVisible
      • ClClearCollect(Collect3, {Result: "All"}); Collect(Collect3, Distinct(Sales, 'Order Number')); ClearCollect(Collect2, {Result: "All"}); Collect(Collect2, Distinct(Sales, Customer.Value))
  • BrowseGallery1
    • Combo Box cmbOrderSearch
      • Items Collect3
    •  Combo Box cmbCustomerSearch
      • Items Collect2
  •  BrowseGallery1
    • Items If(cmbOrderSearch.Selected.Result = "All", Sales, Filter( Sales,'Order Number'=cmbOrderSearch.Selected.Result))

I attempted to amend the equation in "BrowseGallery1 Items" to accommodate the second search but to no avail. Ideally when they filter on a "cmbCustomerSearch",  the result will limit the orders numbers in the  "cmbOrderSearch".

 

I do hope I have explained my self good enough

 

Thankyou in advance

 

Andy

WarrenBelz
Level 8

Re: Filter in a browse screen

Hi @AndrewJRoberts ,

There may be a more elegant way, but the below structure should work - you may have to clean up commas/brackets as I cannot test it. I have allowed for customer number to be blank.

If(
   cmbOrderSearch.Selected.Result = "All", 
   If(
      !isBlank(cmbCustomerSearch),
      Filter(
         Sales,
         cmbCustomerSearch = cmbCustomerSearch.Selected.Result
      ),
      Sales
   ), 
   If(
      !isBlank(cmbCustomerSearch),
      Filter(
         Sales,
         cmbCustomerSearch = cmbCustomerSearch.Selected.Result &&
         'Order Number'=cmbOrderSearch.Selected.Result
      ),
      Filter(
         Sales,
         'Order Number'=cmbOrderSearch.Selected.Result
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

AndrewJRoberts
Level: Powered On

Re: Filter in a browse screen

First of all thank you

 

the only issue is around  the two occurances of "=" in the equation cmbCustomerSearch = cmbCustomerSearch.Selected.Result.  it is under lined in red and the error message reported in the app checker says Invalid Arguement.

WarrenBelz
Level 8

Re: Filter in a browse screen

Hi@AndrewJRoberts ,

You need to rename your combo box - never  name it the same as the field it contains

 

AndrewJRoberts
Level: Powered On

Re: Filter in a browse screen

Sorry Warren

 

I have managed to make a right pigs ear of things and now I have totally confused myself. The issue is still the '=' in the BrowseGallery1 Item equation.

 

  • Browse Screen 1
    • OnVisible
      • ClearCollect(Collect3, {Result: "All"}); Collect(Collect3, Distinct(Sales, 'Order Number')); ClearCollect(Collect2, {Result: "All"}); Collect(Collect2, Distinct(Sales, Customer.Value))
  • BrowseGallery1
    • Combo Box cmbOrderSearch
      • Items Collect3
    • Combo Box cmbCustomerlookup
      • Items Collect2
  • BrowseGallery1
    • Items 
      • If(cmbOrderSearch.Selected.Result = "All",If(!IsBlank(cmbCustomerlookup), Filter(Sales,'Customer' = cmbCustomerlookup.Selected.Result), Sales), If(!IsBlank(cmbCustomerlookup),Filter(Sales,'Customer' = cmbCustomerlookup.Selected.Result &&'Order Number'=cmbOrderSearch.Selected.Result),Filter(Sales,'Order Number'=cmbOrderSearch.Selected.Result)))

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,611)