包含 Filter() 公式的变量的画廊项目

huangapple go评论57阅读模式
英文:

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: &quot;All&quot;
    {
        Roster: &quot;Prescreen&quot;
    }
));

Then set items property of gallery control to:

If(
    Dropdown_Selection.Selected.Roster = &quot;All&quot;,
    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,
    &quot;All&quot;,
    Filter(PT_Table,StartsWith(MRN,Pt_Search_ID.Text)),
    &quot;Prescreen&quot;,
    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.

huangapple
  • 本文由 发表于 2023年2月24日 05:26:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75550470.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定