如何查找整数和文本值(过滤器&搜索)
我通过Power Apps中的应用程序将数据源连接到SQL Server中的数据库,我利用画廊显示数据,并且我有文本条目在该图库中搜索特定数据。
我想执行搜索文本类型数据和数字类型数据的搜索,我在表中使用的数据类型以及我在表中使用的列:
NoEmployee int,
NameEmployee varchar,
Job varchar,
Department varchar,
我正在使用图库中的项目属性来执行两个数字的搜索和文本类型数据我使用以下语法。
Search(Filter(DataSourceEmployee;NoEmployee = Value(txtSearchText.Text));;DataSourceEmployee;txtSearchText.Text;"NameEmployee";"Department";"Job")
上述语法给我以下错误:
'搜索'函数的参数无效
文档我一直在阅读搜索功能不允许我搜索整数值。
然后,结合两个函数的想法在我身上发生,我不知道这是正确的事情。
正如我提到的,我需要搜索我提到的4列,如果使用以下搜索功能,它将在文本类型列中搜索我而毫无问题。
Search(DataSourceEmployee;txtSearchText.Text;"NameEmployee";"Department";"Job")
如果我使用过滤器函数,它将为整数类型列而没有任何问题搜索我。
Filter(DataSourceEmployee;NoEmployee = Value(txtSearchText.Text))
我想知道是否有一种方法可以结合这两个函数,以通过四列执行搜索,或者我可以使用哪些其他功能来搜索数字值,而不会丢失对文本值的搜索。
更新1:
基于提供的最后一个可能的答案,我添加了我使用的语法,但是如果没有获得令人满意的结果,它仅执行与noemployee ,而不是文本类型列。
IfError( Filter(DataSourceEmployee,NoEmployee=Value(txtSearchText.Text)), Filter(DataSourceEmployee,StartsWith(NameEmployee,txtSearchText.Text)))
更新2:
基于他们给我的最后一个答案,我在项目
Gallery Control
的属性中执行了以下功能,我尝试执行搜索类型int
的列以及varchar
的列,而我没有得到结果。
我使用的函数如下:
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
)
附加答案表示我在应用程序控制的onstart
属性中添加的答案。
ClearCollect(colEmployees,DataSourceEmployee)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
sortbycolumn
功能中,而不是search
中使用过滤器
。无论类型如何,您都可以轻松地搜索所有想要的列。在这里,我展示了如何通过所有4列搜索empnumber
是int
-Type列,其余为nvarchar
。您可以按任何列排序
上升
或降序
。插图:
代码:
将其放在应用程序控制的
onstart
上:clearCollect(colemployees,雇员_dev)
lightee_dev
是下面显示的SQL表项目
画廊控制的属性:文本
属性设置为thisItem。< columnName>
数据: sql数据库已连接到PowerApp Canvas App
Use a
Filter
within aSortByColumn
function rather thanSearch
. You can easily search by all columns you want regardless of type. Here I show how to search by all 4 columns whereEmpNumber
is anINT
-type column and the rest areNVARCHAR
.You can sort by any column,
Ascending
orDescending
.Illustration:
Code:
Place this on
OnStart
of the App control:ClearCollect(colEmployees, EMPLOYEE_DEV)
EMPLOYEE_DEV
is the SQL table shown belowPlace this on the
Items
property of the Gallery control:Text
properties toThisItem.<ColumnName>
Data: SQL Database connected to PowerApp Canvas app
您可以利用IFERROR函数以这样的方式,如果搜索框具有字母顺序值,则将搜索图库以获取文本类型列,但是如果搜索框具有数值,则将搜索图库以获取数字类型列。
iferror(
过滤器(dataSource,numerictypepecolumn = value(searchbox.text)),
过滤器(DataSource,StartSwith(TextTypeColumn,searchbox.text))
)
我更喜欢使用startswith函数而不是搜索功能。
You can utilize Iferror function in such a way that if the searchbox has an alphabetical value then the gallery would be searched for text type columns but if the searchbox has a numerical value then the gallery would be searched for the numeric type column.
IfError(
Filter(DataSource,NumericTypeColumn=Value(SearchBox.Text)),
Filter(DataSource,StartsWith(TextTypeColumn,SearchBox.Text))
)
I prefer to use Startswith function instead of Search function.