google sheet : generate increment number - google-sheets

I use this formula:
=filter(calc!B7:B,calc!P7:P="")
to display the data from Col B of 'calc' sheet where the Col P is null or "".
it works fine and it will output single column. If i want to add index number (like incremental ID number) , i normally just manually add any formula that can generate increment number and it works.
But the problem is if the number of the output of that filter() was changed , then i have to readjust the index by extending it or deleting to match the number of the output.
I'm thinking if it's possible to embed the index number (increment number) into the formula itself , for example maybe like this :
=filter({ [my_index_number] , calc!B7:B },calc!P7:P="")
so to generate 2 column, where the left is the custom index_number column. Is it possible ?

Give a try on below formula. Adjust sheet name for other sheet. I have tested the formula to same sheet.
=ArrayFormula(IFERROR(SPLIT(SEQUENCE(COUNTA(FILTER(B7:B,P7:P="")))&"#"&FILTER(B7:B,P7:P=""),"#"),""))

Related

Implement formula in a column based on contents of each cell

In my Google Sheet, I have 1000+ rows of Date entries. For each Date, I am calculating the Month# and Week# using MONTH() and WEEKDAY() functions respectively.
Here is the link to a sample file: https://docs.google.com/spreadsheets/d/1Af5-pYMFWZ1QtLoaAbPZYMGRvk43JBslUp4KyOFADfA/edit?usp=sharing
Problem Statement:
For all rows which have a unique Month# and Week#, I would like to implement a formula and calculate Output. For example, in my sheet, rows 3 to 6 pertain to Month=1 and Week=4. For this set of 5 rows I am calculating Output column as the subtraction from the first element in that set (ie... C3-$C$3, C4-$C$3, C5-$C$3 so on ). Similarly row 7 to 10 pertain to Month=1 and Week=5, and so I calculate Output
as Data-$C$7 and so on.
How do I implement this structure to calculate Output column on each set of unique Month# and Week# values?
Delete everything from Column F (including the F2 header). Then place the following formula into cell F2:
=ArrayFormula({"Output";IF(C3:C="",,IFERROR(C3:C-VLOOKUP(E3:E,{E3:E,C3:C},2,FALSE)))})
This one formula will create the header and return results for all valid rows.
Since VLOOKUP always finds only the first matching instance of what it is looking up, we can use it to ask that each value in C3:C subtract that first instance of where week-number match for each row.
By the way, although you didn't ask about this, you can also use this type of array formula in Columns D and E, instead of all of the individual formulas you have. To do that, delete everything from Columns D and E (including the headers). Then...
Place the following formula in D2:
=ArrayFormula({"Month #";IF(B3:B="",,MONTH(B3:B))})
... and the following formula in E2:
=ArrayFormula({"Week #";IF(B3:B="",,WEEKNUM(B3:B))})

How to repeat a value specified number of times in Google Sheets

How to repeat a value specified number of times in Google Sheets, assuming no overlap or ignoring overlap if any.
Screenshot of the example with ID in column B and Nights in column C.
Trying to reach desired output (column D) with reservation ID repeated the specified number of nights.
Link to example
Your sheet is "Comment only." But try deleting everything from Col D (including the header) and placing the following formula into cell D1:
=ArrayFormula({"ID Full Stay"; IF(A2:A="",,IF(ROW(A2:A)>(VLOOKUP(ROW(A2:A),FILTER(ROW(C2:C),C2:C<>""),1,TRUE) + VLOOKUP(ROW(A2:A),FILTER({ROW(C2:C),C2:C-1},C2:C<>""),2,TRUE)),,VLOOKUP(ROW(A2:A),FILTER({ROW(C2:C),B2:B},C2:C<>""),2,TRUE)))})
This one formula will produce the header (which you can change as you like within the formula itself) and all results for all rows.

google sheet : insert blank column in query output

I tried to extract some column from master table/sheet. I can use query() or filter() or vlookup() but for this example, i use this very simple formula in cell A100 :
={ calc_01!C15:C ,calc_01!F15:F }
It works fine and it will just output 2 columns in A and B column (start from row 100).
The problem is : how if i want the output into 3 column (A,B,C) where the 2nd column or column B will be empty. So i tried something like this , trying to make the 2nd column blank :
={ calc_01!C15:C ,"",calc_01!F15:F }
If i put it on cell A100, i expect the output will occupy column A,B and C (where B is blank). But it doesn't work. So does anyone know if possible to do it ?
Why i want to do this? because i have condition where on the top i have some kind of table formatting where the B column is too narrow and i'm not allowed to adjust its width, so i have to use column c instead of B.
Thanks.
Try
=index({ 'calc_01'!C15:C ,if(row('calc_01'!C15:C),,),'calc_01'!F15:F })
and see if that works?

How do I use minifs with arrayformula so it autopopulates whole column?

Google sheets user here.
I am using the formula minifs to return the lowest match (out of multiple possible match). Is there a way I can use arrayformula as well to auto-populate an entire column so I don't need to copy the same formula to an entire column?
Sample data below:
Column D and J are data manually inputted. Column I is the formula(s).
Essentially what I want to do here is:
Look at Column D - sees the name "Tom"
Sees that "Tom" has 3 scores 100, 90, 70 in Column J
Formula slaps "70" back into Column I because that is the lowest score
Repeats logic for "John" and "Mary"
Note: The actual data type for column J and I is a date instead of a number. But it is easier to illustrate the problem this way.
So I can do this elegantly with the formula: =minifs(J:J,D:D,D2) and D3,D4,D5,D6...etc.
However, I will have to manually drag the formula to the entire column. This is a problem because my colleagues often insert rows in between (and forget to copy n paste the formula to Column I), is there a way I can auto-populate the entire column like I could with an arrayformula?
Assuming your data are A2:C, you can get the min or max of each row by this way: (you can also add a condition in query)
=query(transpose(query(transpose(A2:C),"select " & "min(Col"&arrayformula(textjoin("),min(Col",,row(A2:C)-1))&")")),"select Col2")
https://docs.google.com/spreadsheets/d/1Ia05jywxlvT2amFDG4vQhYOd0lo68FKdOY733MzU-MQ/copy

Sort the value of a column with a relative position (using an other column data order)

I've created a form to collect data from user A in a sheet and reformat it for user B in the other sheet.
I have to sort the data for user B. I'm using vlookup to sort the column of values from the form to a new sheet (sort based on the order of the 'value description column'). It's working.
My problem is that when a new column is added to the first sheet (the form) the column range is modified and the index parameter in vlookup is not good anymore. So I lost everything on my second sheet.
How can I do to have a solid link with the column in the first sheet even if it's position change?
you can make use of INDIRECT with COUNTA and SUBSTITUTE. something like:
=INDIRECT("Sheet1!A1:"&SUBSTITUTE(ADDRESS(1, COUNTA(Sheet1!1:1), 4), 1, "")
this will count non-empty cells in row 1 of Sheet1 and converts that number to later which is used in constructing the range put together by indirect formula and all of it can be placed in vlookup as same as you would place any ther regular range.

Resources