英文:
Gallery Items as variable that contains a Filter() formula
问题
我有一个包含我想要筛选的数据的画廊。为了避免在每个画廊的项目中都有唯一的筛选公式而创建多个画廊,我创建了一个包含所有我想要的筛选/名册的表格。
我在屏幕上有一个下拉菜单,其数据源为这个Roster_Filter_Table。
我尝试了多种方法,例如将项目设置为Dropdown_Selection.SelectedText.Filter,或者让下拉菜单设置/更新上下文中存储筛选公式的变量,然后在我的画廊的项目中使用该变量名称,但所有这些都导致相同的错误:"预期表格"。
我现在非常困惑,不知道如何实现这一点,因为我找不到任何人尝试类似的事情。是否由于PowerApps的限制而无法实现?
英文:
I have a gallery that contains data that I want to filter. To circumvent having multiple galleries with each having unique filter formulas in the gallery's Items, I created a table that contains all the filters/roster I want.
ClearCollect(
Roster_Filter_Table,
Table(
{
Roster: "All",
Filter: "Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text))"
},
{
Roster: "Prescreen",
Filter: "Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text),Eligibility_Status=Blank())"
}
));
I have a dropdown on the screen that has the source as this Roster_Filter_Table.
I've tried multiple things such as making the Items as Dropdown_Selection.SelectedText.Filter or having the dropdown set/updatedcontext of a variable that stores the Filter formula and then use that variable name in my gallery's Items, but all of it yields the same error of "Expected a table".
I'm quite lost now in how I can achieve this as I can't find anyone attempting something similar. Is it impossible to do with the limitations of PowerApps?
答案1
得分: 1
我认为您面临这个问题是因为您将公式创建为字符串/文本。尝试以下方法:
创建这样的集合:
ClearCollect(
Roster_Filter_Table,
Table(
{
Roster: "All",
Filter: Table(Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text)))
},
{
Roster: "Prescreen",
Filter: Table(Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text),Eligibility_Status=Blank()))
}
));
然后将画廊控件的items
属性设置为:
Dropdown_Selection.Selected.Filter
或者
创建这样的集合:
ClearCollect(
Roster_Filter_Table,
Table(
{
Roster: "All"
},
{
Roster: "Prescreen"
}
));
然后将画廊控件的items
属性设置为:
If(
Dropdown_Selection.Selected.Roster = "All",
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text)),
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text),Eligibility_Status=Blank())
)
您还可以使用Switch()
:
Switch(
Dropdown_Selection.Selected.Roster,
"All",
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text)),
"Prescreen",
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text),Eligibility_Status=Blank()),
PT_Table
)
其中最后一个参数(PT_Table
)是在下拉菜单中没有匹配选择时的默认结果。
英文:
I think you are facing this issue because you have created formula as string/text. Try below approach once:
Create collection like this:
ClearCollect(
Roster_Filter_Table,
Table(
{
Roster: "All",
Filter: Table(Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text)))
},
{
Roster: "Prescreen",
Filter: Table(Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text),Eligibility_Status=Blank()))
}
));
Then set items
property of gallery control to:
Dropdown_Selection.Selected.Filter
<hr>
OR
Create collection like this:
ClearCollect(
Roster_Filter_Table,
Table(
{
Roster: "All"
{
Roster: "Prescreen"
}
));
Then set items
property of gallery control to:
If(
Dropdown_Selection.Selected.Roster = "All",
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text)),
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text),Eligibility_Status=Blank())
)
You can also use Switch()
like:
Switch(
Dropdown_Selection.Selected.Roster,
"All",
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text)),
"Prescreen",
Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text),Eligibility_Status=Blank()),
PT_Table
)
Where last parameter (PT_Table
) is the Default Result in case there is no matching selection in drop down.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论