在Power Apps里创建组合筛选器并把值传递给Power公式

本文中我将探索在power app里面创建组合过滤器,并把值传递给Power公式来过滤数据.我使用的是Accounts(样本数据)表来演示,你可以使用自己的数据.控件列表如下:

控件 引用 数据源
Combox Business Account表
Toggle Credit Hold Account表
DropDown(Preview) Relationship Type Account表
Reset 重置控件值 N/A
Table(Preview) Collection Account

整个布局大体如下:

效果如下:

该示例的主要函数是Filter().以下描述来自微软:

Syntax

Filter(Table*, Formula1 [, Formula2, ... ] )

  • Table - Required. Table to search.
  • Formula(s) - Required. The formula by which each record of the table is evaluated. The function returns all records that result in true. You can reference columns within the table. If you supply more than one formula, the results of all formulas are combined with the And function.

注意in和exactin的用法(子字符串匹配).当使用 Combox、DropDown、List 等控件时,这些数据是table类型。因此,例如使用 Combox 时,我会首先考虑in运算符。以下是Account表中的数据,我想过滤业务类型("EMS"、"OEM")。

代码类似于:

vbnet 复制代码
FROM Account WHERE 'Business Type' IN ( Combox.dataset)
//It's not a real code, I want to use T-SQL to explain it.

把整个解释为Power fx公式:

scss 复制代码
Filter(Account, 'Business Type' in Combox.SelectedItems)

或者我们缩小下值的范围,使用ShowColumns()的函数,它将删除其他列并仅返回您想要的列,这里是Value列,注意,即使它只有一列,它的类型依然是Table类。

java 复制代码
Filter(Account, 'Business Type' in ShowColumns(Combox.SelectedItems,Value))

类似地,我们可以组合其他控件,然后把它们的值传递给Power fx公式来实现筛选的效果.以下是详细步骤:

1. 设置Combox的数据源:

ini 复制代码
Items = Choices('Business Type (Accounts)')
IsSearchable = false //default is true.

2. 设置DropDown的数据源:

ini 复制代码
Items = Choices('Relationship Type (Accounts)')DefaultSelectedItems= []

3. 重置控件的OnSelect.

scss 复制代码
OnSelect = Reset(ComboBox1);Reset(DropdownCanvas2);

4. 添加Button,设置OnSelect.

less 复制代码
ClearCollect(
    myAccount,
    RenameColumns(
        ShowColumns(
            Filter(
                Accounts,
                (IsBlank(ComboBox1.SelectedItems) || 'Business Type' in ComboBox1.SelectedItems) 
                And (IsEmpty(DropdownCanvas2.SelectedItems) || 'Relationship Type' in ShowColumns(
                    DropdownCanvas2.SelectedItems,
                    Value
                )) 
                And 'Credit Hold' = Toggle1.Checked
            ),
            'Account Name',
            'Main Phone',
            'Address 1: City',
            'Primary Contact',
            'Credit Limit'
        ),
        name,'Customer Name',
        address1_city,'City',
        creditlimit,'Credit Limit',
        primarycontactid,'Primary Contact',
        telephone1,'Main Phone'
    )
)
相关推荐
低代码布道师9 小时前
微搭低代码MBA 培训管理系统实战 41——审批中心
低代码
踩着两条虫9 小时前
「AI + 低代码」的可视化设计器
开发语言·前端·低代码·设计模式·架构
2601_9577875815 小时前
全场景矩阵系统低代码平台:企业级业务快速定制与扩展技术实践
低代码·可视化开发·流程编排
Jeking21718 小时前
低代码平台表单设计器 unione form editor 组件介绍--随机输入组件
低代码·动态表单·表单设计·表单引擎·unione cloud
Jeking21718 小时前
低代码平台表单设计器 unione form editor 组件介绍--单选组件
低代码·动态表单·表单设计·表单引擎·unione cloud
UXbot21 小时前
支持移动端原型绘制的 AI 工具核心功能对比(2026):5 款主流平台能力横向评测
前端·低代码·ui·交互·原型模式·web app
IT研究所1 天前
AI 时代下的知识管理:从 Claude 的“复盘”能力看生成式 AI价值
大数据·运维·数据库·人工智能·科技·低代码·自然语言处理
Jeking2172 天前
低代码平台表单设计器 unione form editor 组件介绍--文件上传
低代码·动态表单·表单设计·表单引擎·unione cloud
Jeking2172 天前
低代码平台表单设计器 unione form editor 组件介绍--复选组件
低代码·动态表单·表单设计·表单引擎·unione cloud
Jeking2173 天前
低代码平台表单设计器 unione form editor 组件介绍--下拉树
低代码·动态表单·表单设计·表单引擎·unione cloud