英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论