I have my data source connected to database in SQL Server through an application in Power Apps, I am making use of Gallery to display the data and I have a text entry to search for specific data in that gallery.
I would like to perform the search for text type data and numeric type data, I leave below the data type and the columns that I use in my table:
NoEmployee int,
NameEmployee varchar,
Job varchar,
Department varchar,
I am making use of the Items property in the Gallery to perform the search for both numeric and text type data where I use the following syntax.
Search(Filter(DataSourceEmployee;NoEmployee = Value(txtSearchText.Text));;DataSourceEmployee;txtSearchText.Text;"NameEmployee";"Department";"Job")
The above syntax gives me the following error:
'Search' function has invalid arguments
Among the documentation that I have been reading the Search function does not allow me to search for integer values.
Then the idea of combining the two functions occurs to me, I don't know if it's the right thing to do.
As I mentioned, I need to search for the 4 columns that I mentioned, if I use the following Search function, it searches me without problem for the text type columns.
Search(DataSourceEmployee;txtSearchText.Text;"NameEmployee";"Department";"Job")
If I use the Filter function, it searches me without any problem for the integer type column.
Filter(DataSourceEmployee;NoEmployee = Value(txtSearchText.Text))
I would like to know if there is a way to combine these two functions in order to perform the search through the four columns or what other function I can use to search for number values without losing the search for text values.
Update 1:
Based on the last possible answer provided, I add the syntax that I have used, but without obtaining a satisfactory result, it only performs a search for the numeric data type column which corresponds to NoEmployee
and not for the text type column.
IfError( Filter(DataSourceEmployee,NoEmployee=Value(txtSearchText.Text)), Filter(DataSourceEmployee,StartsWith(NameEmployee,txtSearchText.Text)))
Update 2:
Based on the last answer they give me I have performed the following function in the Items
property of Gallery Control
, I try to perform the search for the column of type INT
as well as those of VARCHAR
and in none I get results.
The function I have used is as follows:
SortByColumns(
Filter(
colEmployees,
If(
!IsBlank(txtSearchText.Text),
Or(
txtSearchText.Text in NoEmployee,
txtSearchText.Text in NameEmpleado,
txtSearchText.Text in Job,
txtSearchText.Text in Department
),
1 = 1
)
),
"NoEmployee",
Ascending
)
Additional as the answer indicates I have added in the OnStart
property of the application control the following:
ClearCollect(colEmployees,DataSourceEmployee)