ListRemove() or [list] - [thisRow]

The solution within the topic you shared already uses Splice() :innocent:

See the If() within the quote above :point_up: :blush:

I’ll admit that the whole solution within that topic seems a bit complicated to read, because of all the nested WithName() (which are there to avoid some redundancy)… but I find it elegant :blush: .

Now, in a far less elegant way but maybe easier to grasp, here’s an action button also doing what was asked in the topic you shared :blush: … Which I’m just sharing trying to answer your question :innocent:
(You’ll find the sample below :blush: )

If(thisRow.Going.Not(),
  ModifyRows(                                  //Click 1: Add the player
    Games.Filter(Date = nextGame),
    Games.RSVPs,
    ListCombine(
      Games.RSVPs.Filter(CurrentValue.IsNotBlank()),
      thisRow
      )
  ),
  ModifyRows(                                 //CLICK 2: Remove the player
    Games.Filter(Date = nextGame),
    Games.RSVPs,
    Games.Filter(Date = nextGame).First().RSVPs.WithName(CurrentList,
      Splice(
        CurrentList,
        CurrentList.Find(thisRow),
        1
      )
    )
  )
)

In the “Click 2” action (the 2nd ModifyRows()) there’s this bit of formula :

 Games.Filter(Date = nextGame).First().RSVPs.WithName(CurrentList,
      Splice(
        CurrentList,
        CurrentList.Find(thisRow),
        1
      )
    )

And what it does is:

  • It takes the table Games and look for the rows where CurrentValue.Date is equal to the nextGame (the date on the canvas).
    This actually returns a list of 1 row from the table Games. So, to effectively get the row from that list of 1 row, I’ve appended First() to the Filter().
  • Now that we have the appropriate row, we can access the values in the field RSVPs. (I.e.: the list of players)
  • As I’m going to need that list in Splice() and to avoid repeating the Filter(), I’m storing the list within the named value CurrentList using WithName()
  • All that’s left to do is to Splice() the CurrentList according to the position of thisRow (which Find() helps us retrieve) within the CurrentList
     Splice(
            CurrentList,               //Value
            CurrentList.Find(thisRow), //Start - (Where to begin to delete)
            1                          //deleteCount - How many to delete 
         )
    

Now, I’m not saying this doesn’t require a bit of work though :blush:… But I hope this helps :blush:

1 Like