Run filter in each row dynamically - google-sheets

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.

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")),
""))),
","))

As of today (23-Jan-2023), it appears that Google has updated the BYROW/BYCOL functions to allow the return of an array result per row/column, so the answer to the OPs question could now simply be =byrow(range,lambda(row,filter(row,row<>""))).
I have not seen this documented anywhere, and the help pages for the BYROW & BYCOL functions still state that only a single value per row/column is allowed.
Slightly off-topic, but I can also confirm that you can pass the individual row/columns from a BYROW/BYCOL into the other LHFs as well (e.g. a SCAN within a BYROW to give a row-wise running total, etc.)

Related

Google sheets fill in the gaps using array formula

I have this table and the date column has some blanks if the dates are the same.
i.e. B3:B6 are all 31/01/2022
I want to use column F to fill in the gaps.
I would like to use an arrayformula in cell F2 and it stops when the relative A is empty
i.e. if A279 is empty, F279 is empty too.
I tried to do it using a non-array solution
=IF(B2="",F1,B2)
and I cannot change it to array one
=ArrayFormula(IF(B2:B="",F1,B2:B))
I don't know how to make F1 dynamic and the row number is always one less then B, like showing F2 if B3, F3 if B4
This is the Sheet
Try in F2
=ArrayFormula(lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B))
or (better) in F1
={"Date";ArrayFormula(if(A2:A="",,lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B)))}
to understand how it works, pls fill for instance in I2 =arrayformula(if(A2:A="",,row(A2:A)/--(B2:B<>""))) ... if Bx is blank, we get an error, in that case lookup will take the previous value without error.

Filter and sort results, ignoring rows with no data, with 2, 3 or 4 conditions

I have a large database from Y to BF.
Columns Y to AB are the categories of all the rest.
I want to apply a filter function that will only filter results with rows with data (ignore all other columns/rows blank).
Conditions for Filter are in B2 ; D2 ; F2 ; H2 .
I also want to be able to Sort results according to O2 and in a Ascending or Descending order according to Q2.
In A6 I have a formula that only shows titles with corresponding data, BUT it doesn't respect possible 4 conditions, only one, the first in B2
=FILTER( AD2:AJ2,INDEX(AD2:AJ,MATCH( B2,Y3:Y,0 ),)<>"" )
In A7 i have a formula (not working) that only fills filtered results according with B2 + D2 + F2 + H2 BUT doesn't show only rows with data, it shows all columns
=IFERROR(SORT(FILTER(AD3:BF,
IF(B2="",ROW(Y3:Y),Y3:Y=B2)*
IF(D2="",ROW(Z3:Z),Z3:Z=D2)*
IF(F2="",ROW(AA3:AA),AA3:AA=F2)*
IF(H2="",ROW(AB3:AB),AB3:AB=H2)),
IF(O2="",1,MATCH(O2,A6:R6,0)),
IF(Q2="Asc",1,0)),"Sem Navios")
My difficulty is that my current formulas respect the 4 conditions (even in case some one is blank) BUT does not filter columns only with data, it spills all columns and that is very confusing.
Can someone help me getting to filter data according to 4 conditions (even in case some one is blank), being able to sort and only shows rows with data?
Thanks.
Example sheet here https://docs.google.com/spreadsheets/d/11B-4rjP9_8brvF0A3yVJlIoiyXWqxM91qWtKRSD8tLI/edit?usp=sharing
Feel free to edit.
I have a "desired results" tab, with no formulas, just showing what I pretend.

Create 3 output results (rows) from one cell (Google Sheets)?

I found an issue, and I do not know if the title explains it precisely, but I somehow need to create 3 different output results (rows) based on the value in one;
I want to only enter one value in cells A2, A3, A4 (maybe have the cells merged?), the same in B2, B3, B4; C2, C3, C4 and D2, D3, D4. But in column E I need 3 output results for one value in B2.
What would be the most efficient way to do that?
Here is the sheet that I am working on:
https://docs.google.com/spreadsheets/d/1PYPjFr3Ny_ycDJ0PEgdd3y7VAW6J32RGtqqPLDIyXQ4/edit?usp=sharing
How can I do that with one formula based on value in B2 I will get 3 output results in column E that will concatenate string "MO_MED_" with B2 and add different endings _EDITABLE, _REQUIRED, _VISIBLE?
Just to make an explicit answer, the correct way to proceed here would be to use the CONCATENATE.

google sheets, use formula output for next formula

I'm trying to CONCATENATE two cells in order to compare the results so that I can search by them, however the values of the two CONCATENATE outputs are different as one inputs is coming from the another formula.
Screen shots attached
I'm basically trying to compare the start time and channel number from A and B, with the data from G and H, so that I can update D with the relevant information in F (in the same format as A).
I first convert the EPOC time to human time readable, but when i try and CONCATENATE with the channel number, I get a different value to when i do that with A and B.
formula for c2 =CONCATENATE(A2,B2)
formula for i2 =G2/86400000+date(1970,1,1)
formula for k2 =CONCATENATE(G2,H2)
As you can see, the values for c2 and k2 are different event though a2 and i2 are the same (looking).
I've tried using CELL, INDEX, and INDIRECT but just can't seem to get it right, and I've tried various formatting options
Hopefully i've explained this right. Any solution welcome
raw data csv here START ,CHANNEL,concat,end?,,EndDateTime epoc,startDateTime epoc,channel,converted start,converted end,concat
12:58:00 AM,10,,,,1520391600000,1520382480000,7,,,
12:28:00 AM,7,,,,1520395200000,1520384280000,10,,,
So you have a couple of issues here.
CONCATENATE(A2,B2) will never equal CONCATENATE(I2,H2) because the values in A2 (12:58) and B2 (10) do not equal the values in I2 (12:28) and H2 (7). I think you meant to compare A2,B2 to I3,H3
A2 (12:58) does not equal I3 (12:58). You'll see this for yourself if you convert both to the date or number formats. The date value of A2 is 12/30/1899, the default when you enter only a time in the cell. The date value of I3 is 3/7/2018, because you converted the exact date and time from the EPOCH value.
For the two concatenations to equal each other, you need to resolve the issues above. You can do this by adding a date to column A's values.
On another note, I think there are better ways of populating column D based on the data in column F. A simple Vlookup should do the trick, once you resolve issue #2 above.

Google Sheets - Multipling a cell(weight) by another(rate) based on its value compared to a column of cells

I want to compare the value of cell(K5) against column A to determine the range its rate will fall under. Once the proper rate is determined, I want to multiply that row with its values on column B, C, etc and output it on cells (L5, M5, etc)
for example if the CW(K5) is 755.5 then its range falls under cell A8(500+) so we can multiply CW(K5) by B8 and C8 and output the product on L5, M5 respectively.
Eventually I will have many more rows so is probably a better idea to have rates(columns A, B, C) in a separate sheet, is that even possible?
the actual sheet
I've made similar data sheet, but removed strings with actual numbers to look for in column A. And then used vlookup for sorted range A:C:
The formula for F2 is:
=VLOOKUP(E2,$A:$C,2)
The formula for G2 is:
=VLOOKUP(E2,$A:$C,3)
This technique may help you.

Resources