你能在PowerApps中通过一种条件或另一种条件筛选表格/集合吗?

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

Can you filter a table/collection in PowerApps by one thing OR another?

问题

我正在尝试在PowerApps中过滤一个集合,如下所示:

Filter(AllRooms, "ComputerRoom" || "LaptopRoom" in Name)

然而,当我尝试这样做时,没有任何房间显示出来。如果我只使用一个过滤器("ComputerRoom"或"LaptopRoom"),则正确的房间会显示出来。这是语法问题吗?还是有些事情是不可能的?

AllRooms 包含:

"ComputerRoom 1"
"ComputerRoom 2"
"ComputerRoom 3"
"LaptopRoom A"
"LaptopRoom B"
"ClassRoom 1"
"ClassRoom 2"
"ClassRoom 3"
"ClassRoom 4"
英文:

I'm trying to filter a collection in PowerApps like so:

Filter(AllRooms, "ComputerRoom" || "LaptopRoom" in Name)

However when I try this none of my rooms come up. If I use only one filter ("ComputerRoom", or "LaptopRoom") then the correct rooms come up. Is this is syntax thing? Or something that just isn't possible?

AllRooms contains;

"ComputerRoom 1"
"ComputerRoom 2"
"ComputerRoom 3"
"LaptopRoom A"
"LaptopRoom B"
"ClassRoom 1"
"ClassRoom 2"
"ClassRoom 3"
"ClassRoom 4"

答案1

得分: 1

你可以使用以下表达式根据一个值或另一个值来筛选房间:

Filter(AllRooms, "ComputerRoom" in Name || "LaptopRoom" in Name)

|| 运算符可用于组合两个布尔(true/false)值;当用于你最初的问题时,它实际上试图将值 "ComputerRoom" 和 "LaptopRoom" 转换为布尔值,然后进行“或”操作,这就是为什么它不按你的预期工作的原因。

英文:

You can use the following expression to filter the rooms based on one value or the other:

Filter(AllRooms, "ComputerRoom" in Name || "LaptopRoom" in Name)

The || operator can be used to combine two Boolean (true/false) values; when used as your original question, it is actually trying to convert the values "ComputerRoom" and "LaptopRoom" to boolean values before "or-ing" them, which is why it's not working as you expect.

huangapple
  • 本文由 发表于 2023年7月11日 00:50:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655806.html
匿名

发表评论

匿名网友

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

确定