Skip to main content

Notifications

Community site session details

Community site session details

Session Id : xcHL0dAwN7lALXRbKrOJqe
Power Apps - Building Power Apps
Answered

Remove from collection based on criteria

Like (0) ShareShare
ReportReport
Posted on 9 Sep 2022 21:39:47 by 93

Hi,

I have two collections
ColBooked

LaptopBookedOnTimeSlotLaptopID
Laptop A10 Sep 202212:00-13:00LP101A
Laptop A10 Sep 202215:00-14:00LP101A
Laptop B10 Sep 202212:00-13:00LP102B

 

ColToCancel

LaptopBookedOnTimeSlotLaptopID
Laptop A10 Sep 202212:00-13:00LP101A
Laptop B10 Sep 202212:00-13:00LP102B

 

How do I remove the items from ColToBook that exist in ColToCancel?

Categories:
  • Verified answer
    EricBLott Profile Picture
    248 on 10 Sep 2022 at 12:59:33
    Re: Remove from collection based on criteria

    Ideally, you could add a unique ID for each slot. However, if that's not possible, you can do this:

    ClearCollect(colBookedUnique,AddColumns(colBooked,"laptopSlotId",Concatenate(LaptopID,BookedOn,TimeSlot)));
    With(
     {
     colToCancelUnique: AddColumns(colToCancel,"laptopSlotId",Concatenate(LaptopID,BookedOn,TimeSlot))
     },
     RemoveIf(
     colBookedUnique, laptopSlotId in colToCancelUnique.laptopSlotId)
    );
    ClearCollect(colBooked,DropColumns(colBookedUnique,"laptopSlotId"));

    This creates a unique column by concatenating the timeslot, date, and laptop ID columns together, filters that temporary collection, then ClearCollect()s it into the colBooked collection.

  • I_Mo Profile Picture
    93 on 10 Sep 2022 at 08:26:26
    Re: Remove from collection based on criteria

    Thanks @EricBLott . I have tried this method already, but as you can see I do not want to remove all that match the LaptopID. I want to remove only those that match the date and time for each LaptopID in ColToCancel.

  • EricBLott Profile Picture
    248 on 09 Sep 2022 at 21:45:14
    Re: Remove from collection based on criteria

    Here is the documentation for the RemoveIf() function.

    https://docs.microsoft.com/en-us/power-platform/power-fx/reference/function-remove-removeif

     

    You can use that function like this:

    RemoveIf(ColToBook,LaptopID in ColToCancel.LaptopID)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 10

#2
LC-26081402-0 Profile Picture

LC-26081402-0 6

#3
EE-04041031-0 Profile Picture

EE-04041031-0 4

Overall leaderboard
Loading started