Hi,
I have two collections
ColBooked
Laptop | BookedOn | TimeSlot | LaptopID |
Laptop A | 10 Sep 2022 | 12:00-13:00 | LP101A |
Laptop A | 10 Sep 2022 | 15:00-14:00 | LP101A |
Laptop B | 10 Sep 2022 | 12:00-13:00 | LP102B |
ColToCancel
Laptop | BookedOn | TimeSlot | LaptopID |
Laptop A | 10 Sep 2022 | 12:00-13:00 | LP101A |
Laptop B | 10 Sep 2022 | 12:00-13:00 | LP102B |
How do I remove the items from ColToBook that exist in ColToCancel?
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.
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.
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)
MS.Ragavendar
10
LC-26081402-0
6
EE-04041031-0
4