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

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
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.
3 REPLIES 3
Highlighted
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.

 

 

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.
opticshrew2
Level: Powered On

Re: Mutliple search criteria using numeric/int fields.

@RandyHayes 

 

That worked a treat!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 205 members 5,687 guests
Please welcome our newest community members: