Search code examples
logicoperatorspowerapps

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


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"

Solution

  • 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.