将多个状态值分组以在PowerApp中筛选画廊。

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

Group Multiple status values to filter gallery in PowerApp

问题

我有一个包含多列的SharePoint数据源。
其中一列包含每个任务的状态。

列的值有

新建,等待批准,一级批准,二级批准,财务批准,财务拒绝,批准拒绝,草稿。

有一个下拉菜单用于筛选画廊项目。我想按照以下方式对上述列的状态值进行分组,以便单个选择的值可以显示具有不同状态的订单,例如:

下拉菜单值1 - "全部"(包含所有状态值)
下拉菜单值2 - "新建" - 应过滤具有状态(新建,等待批准)的任务
下拉菜单值3 - "被拒绝" - 应过滤具有状态(财务拒绝,批准拒绝)的任务
下拉菜单值4 - "进行中" - 应过滤具有状态(一级批准,二级批准)的任务

如何实现这一点?

提前感谢

尝试过但未成功

SortByColumns(
  Filter(
    Orders,
    UserOrderStatusdd.Selected.Value = "全部"
      || OrderStatus.Value = UserOrderStatusdd.Selected.Value
      || UserOrderStatusdd.Selected.Value = "已完成",
      OrderStatus.Value = "财务待批准"
      || UserOrderStatusdd.Selected.Value = "被拒绝",
      OrderStatus.Value = "被拒绝"
      || UserOrderStatusdd.Selected.Value = "进行中",
      OrderStatus.Value in "一级批准", "二级批准"
    ),
  "OrderID",
  SortOrder.Descending
)
英文:

I have SharePoint data source with multiple columns.
One column includes the Status for each task.

Columns values are

New, Waiting for approval, Level 1 Approved, Level 2 Approved, Finance Approved, Reject by Finance, Rejected by Approved, Draft.

There is a dropdown for filter gallery items. I want to group the status values of the above column as follow so a single selected value can show orders with different status such as:

Dropdown Value 1 - "All" (contains all status values)
Dropdown value 2 - "New" - It should filter the tasks with status (New, Waiting for approval)
Dropdown value 3 - "Rejected" - It should filter the tasks with status (Reject by Finance, Rejected by Approved)
Dropdown value 4 - "In Progress" - It should filter the tasks with status (Level 1 Approved, Level 2 Approved)

How can I achieve this ?

Thanks in advance

Tried this but not working

SortByColumns(
  Filter (
    Orders,
    UserOrderStatusdd.Selected.Value = "All"
      || OrderStatus.Value=UserOrderStatusdd.Selected.Value 
      || UserOrderStatusdd.Selected.Value = "Completed" , OrderStatus.Value = "Finance Approval Pending" 
      || UserOrderStatusdd.Selected.Value = "Rejected", OrderStatus.Value = "Rejected" 
      || UserOrderStatusdd.Selected.Value = "In Progress", OrderStatus.Value in "L1Approved", "L2Approved"
    ),
  "OrderID",
  SortOrder.Descending
)

答案1

得分: 1

SortByColumns(
  Filter(
    Orders,
    Or(
      UserOrderStatusdd.Selected.Value = "All",
      And(
        UserOrderStatusdd.Selected.Value = "New",
        Or(
          OrderStatus.Value = "New",
          OrderStatus.Value = "Waiting for approval"
        )
      ),
      And(
        UserOrderStatusdd.Selected.Value = "Rejected",
        Or(
          OrderStatus.Value = "Reject by Finance",
          OrderStatus.Value = "Reject by Approver"
        )
      ),
      And(
        UserOrderStatusdd.Selected.Value = "In Progress",
        Or(
          OrderStatus.Value = "Level 1 Approved",
          OrderStatus.Value = "Level 2 Approved"
        )
      )
    )
  ),
  "OrderID",
  SortOrder.Descending
)
英文:

You can use an expression like the one below. I'm using the "function version" of the And (&&) / Or (||) operators to make it easier to see the nesting, but feel free to use the operators as you were if you prefer.

SortByColumns(
  Filter (
    Orders,
    Or(
      UserOrderStatusdd.Selected.Value = "All",
      And(
        UserOrderStatusdd.Selected.Value = "New",
        Or(
          OrderStatus.Value = "New",
          OrderStatus.Value = "Waiting for approval"
        )
      ),
      And(
        UserOrderStatusdd.Selected.Value = "Rejected",
        Or(
          OrderStatus.Value = "Reject by Finance",
          OrderStatus.Value = "Reject by Approver"
        )
      ),
      And(
        UserOrderStatusdd.Selected.Value = "In Progress",
        Or(
          OrderStatus.Value = "Level 1 Approved",
          OrderStatus.Value = "Level 2 Approved"
        )
      )
    )
  ),
  "OrderID",
  SortOrder.Descending
)

huangapple
  • 本文由 发表于 2023年3月15日 21:10:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75745197.html
匿名

发表评论

匿名网友

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

确定