Google sheets fill in the gaps using array formula - google-sheets

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.

Related

Run filter in each row dynamically

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.)

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.

Let user input a value in a cell containing a formula

I have a table that looks like this:
I'm not very familiar with google sheets yet, and I am looking for a way to allow users to input a value in one of the 4 cells containing a formula. Then the other cells would update according to the value the user entered in the cell he chose.
So if a user enters a value in B2 : B3 B4 and B5 would run the formula according to B2's value. And if then if he chooses to enter another value for B4 : B2 B3 and B5 would update accordingly.
I am not sure if what I have in mind is the correct way to do this, or if it is even possible at all. Any ideas on how to proceed?
I just answer according to my understanding, maybe I'm wrong to understand. I think you just paste your formula's in column c and allow your users to put values in B column, this is the way formula do automatic it for you. Sorry for bad English
I mean to put this in column c =B4/4 like bellow
and you get result like bellow
if you want to have custom inputs for values B2, B3, B4, B5 populate these cells with numbers and put your formulas in C column:
if you want to have custom inputs for values 4, 60, 30 then do it like this:

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