cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Mutliple search criteria using numeric/int fields.

Hi all,

 

I have an Azure SQL Database with mulitple tables. The "main" table has the following schema:

 

ID  -- int
Type -- int
Status -- int Name -- varchar()

 

 

I'm wanting to search agains the table and have tried the following formulas:

Case 1

 

Filter(
        [TABLE],
        Type = Combo_1.Selected.ID,
        Status = Combo_2.Selected.ID
)

 

  • This means both fields need populating (I may only populate the 1 field and still want it to return values)

Case 2

 

Search(
    [TABLE], 
    Combo_1.Selected.ID, 
    "Type" 
)

 

  • This means only a single field can be used
  • This doesn't work as a string is expected

Has anyone had this issue previously?


Regards,

J

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Mutliple search criteria using numeric/int fields.

@opticshrew2 

So, in general, your formulas are doing as expected (for the functions you have).

I believe though, if I'm understanding you correctly, that you might want to consider these options:

 


I'm wanting to search agains the table and have tried the following formulas:

Case 1

 

Filter(
        [TABLE],
        Type = Combo_1.Selected.ID,
        Status = Combo_2.Selected.ID
)

 

CHANGE TO:

Filter(
          [TABLE],
          Type = Combo_1.Selected.ID || Status = Combo_2.Selected.ID
        )
  • This means both fields need populating (I may only populate the 1 field and still want it to return values)

Based on your point above, it appears that you want to return results from either field or both.  If that is correct, then the above Change formula will provide those results.

When you separate your conditions in the filter as separate parameters as you did in your first formula, the Filter function will AND the conditions.  In this case you want OR, so the changed formula provides the OR ( || ) operator to do it.

Case 2

 

Search(
    [TABLE], 
    Combo_1.Selected.ID, 
    "Type" 
)

 

  • This means only a single field can be used
  • This doesn't work as a string is expected

The Search function Only works on text fields.  In this case you are trying to search an integer column which is not allowed.  You can replace the formula with the Change formula (in the previous Case) above to achieve the same results.


 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Mutliple search criteria using numeric/int fields.

Hi @opticshrew2 

I think this is the type of syntax you're looking for:

 

 

Filter(
        [TABLE],
        (IsBlank(Combo_1.Selected.ID) || Type = Combo_1.Selected.ID) &&
        (IsBlank(Combo_2.Selected.ID) || Status = Combo_2.Selected.ID)
)

To describe briefly the condition that applies to the Type column, a blank selection for Combo_1 is blank OR (Type = Combo_1.Selected.ID) will resolve to true. This is the logic that enables us to conditionally filter by a combobox value. Hopefully, that makes sense, but post back if it doesn't.

 

 

Highlighted
Super User
Super User

Re: Mutliple search criteria using numeric/int fields.

@opticshrew2 

So, in general, your formulas are doing as expected (for the functions you have).

I believe though, if I'm understanding you correctly, that you might want to consider these options:

 


I'm wanting to search agains the table and have tried the following formulas:

Case 1

 

Filter(
        [TABLE],
        Type = Combo_1.Selected.ID,
        Status = Combo_2.Selected.ID
)

 

CHANGE TO:

Filter(
          [TABLE],
          Type = Combo_1.Selected.ID || Status = Combo_2.Selected.ID
        )
  • This means both fields need populating (I may only populate the 1 field and still want it to return values)

Based on your point above, it appears that you want to return results from either field or both.  If that is correct, then the above Change formula will provide those results.

When you separate your conditions in the filter as separate parameters as you did in your first formula, the Filter function will AND the conditions.  In this case you want OR, so the changed formula provides the OR ( || ) operator to do it.

Case 2

 

Search(
    [TABLE], 
    Combo_1.Selected.ID, 
    "Type" 
)

 

  • This means only a single field can be used
  • This doesn't work as a string is expected

The Search function Only works on text fields.  In this case you are trying to search an integer column which is not allowed.  You can replace the formula with the Change formula (in the previous Case) above to achieve the same results.


 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Helper II
Helper II

Re: Mutliple search criteria using numeric/int fields.

@RandyHayes 

 

That worked a treat!

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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