Home > Software engineering >  Run filter in each row dynamically
Run filter in each row dynamically

Time:11-02

I'm trying to manage a dynamic set of data over the course of several steps, and at each step I need to remove a specific value from each row, and shift the remaining values to the left to fill in any blanks.

I know I can use

=arrayformula(if(range=value, "", range)) 

to remove the specific value, but I've only been able to find

=filter(row, row<>"") 

to fill in the blanks, but since the number of rows changes, this isn't going to work.

Edit:

I want to turn something like this

Column A Column B Column C
Data A1 Data B1 Data C1
Data A2 Data B2 Data C2
Data A3 Data B3 Data C3
Data A4 Data B4 Data C4
etc etc etc

to this

Column A Column B Column C
Data A1 Data C1
Data A2 Data B2 Data C2
Data B3 Data C3
Data C4
etc etc etc

Since I only know how many columns there are, I can only pre-set the formula to filter each column, which moves data vertically. I want to move it horizontally, but where the number of rows is variable, I can't manually pre-set each row to use filter.

CodePudding user response:

Solution: applying FILTER() in combination with BYROW(). Because Google's BYROW() is unfortunately limited to a single value return from it's LAMBDA(), we have to rely on the old ARRAYFORMULA/JOIN/SPLIT trick.

=arrayformula(
   split(
     byrow(A1:C4, 
           lambda(row,
                  ifna(
                    join(",",
                         filter(row, row<>"A")),
                    ""))),
     ","))

enter image description here

  • Related