cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
opticshrew2
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
RandyHayes
Super User
Super User

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
timl
Super User
Super User

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.

 

 

RandyHayes
Super User
Super User

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
opticshrew2
Helper II
Helper II

@RandyHayes 

 

That worked a treat!

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,506)