I'm aware that it's possible to emulate a for loop in Google Sheets via the following:
=ARRAYFORMULA(IF(LEN({range_0 to iterate over}),{function_0 for each element in range_0}))
I've not been able to expand on the above approach to achieve the effect of a multi nested for loop. Is this possible? Ideally this would look something like:
=ARRAYFORMULA(IF(LEN({range_0 to iterate over}),IF(LEN({range_0.1 to iterate over for each parent element in range_0}),{function_0.1 for each element in range_0.1},{OPTIONAL: function_0 for each element in range_0})))
Example application:
Iterating over each cell in a row for each row in a column (see below; I'm sure there are ways to achieve this effect via other methods, but I have use for the requested and specified method for cases where a single dynamic formula is necessary to keep up with an unknown and changing number of rows, columns, and functions involved):
Raw data:
Thing
Type
Feature
Cost
Apple
Fruit
Seeds
$1
Car
Automobile
Wheels
$6,000
Laptop
Computer
Keyboard
$500
Grape
Fruit
Tastiness
$0.50
Theoretical formula:
=ARRAYFORMULA(IF(LEN(`Thing`),IF(LEN(COLUMNS({current row of `Thing`})),{current cell in current row of `Thing`} & " of column " & COLUMN({*current cell*}) & " and row " & ROW(`Thing`),""),""))
Output of above theoretical formula:
Thing
Type
Feature
Cost
Apple of column 1 and row 3
Fruit of column 2 and row 3
Seeds of column 3 and row 3
$1 of column 4 and row 3
Car of column 1 and row 4
Automobile of column 2 and row 4
Wheels of column 3 and row 4
$6,000 of column 4 and row 4
Laptop of column 1 and row 5
Computer of column 2 and row 5
Keyboard of column 3 and row 5
$500 of column 4 and row 5
Grape of column 1 and row 6
Fruit of column 2 and row 6
Tastiness of column 3 and row 6
$0.50 of column 4 and row 6
Thank you for your help!
try:
=ARRAYFORMULA(IF(LEN(A3:E7), A3:E7&" of column "&COLUMN(A3:E7)&" and row "&ROW(A3:E7), ))
Related
I have large number of rows of data in Excel where I need to change the row array of the formula for every 3 rows but I can't figure out how to adjust the formula without an error.
How do I add a formula like this to the formula below?
=INT(((ROW(a1)-1)/11))*1+1
This is the formula I have been using, but I need to change it for every 3 rows.
=IF(COUNTIF($N$4:$N$6, ""), "",MAX($N$4:$N$6))
=IF(COUNTIF($N$7:$N$9, ""), "",MAX($N$7:$N$9))
And so on
Example
I have 3 approvers, if "product" is approved, the date is for the approval date of last said approval, if no approval has been made then the cell is blank. Outcome is what I want to collect from column 3 when product was approved from all 3 approvers which is the newest date of the 3 rows, if one approver has not approved, then I'd like column 4 to be blank.
Product
Approvers
Dates
Outcome
A
1
04.01.2016
04.01.2016
A
2
17.12.2015
04.01.2016
A
3
21.12.2015
04.01.2016
B
1
11.04.2017
11.04.2017
B
2
30.01.2017
11.04.2017
B
3
04.04.2017
11.04.2017
C
1
C
2
13.10.2016
C
3
14.02.2017
D
1
01.03.2022
01.03.2022
D
2
02.12.2019
01.03.2022
D
3
30.01.2020
01.03.2022
Picture of data
Two options:
To answer the original question, to make your formula change every n rows, use =-MOD(ROW()+c, n) to adjust this (where 'c' is a constant just to get them in line, if your data starts on row 2 then c would be 1).
Your formula for row 2 would be:
=IF(COUNTIF(OFFSET($N2,-MOD(ROW($N2)+1,3),0,3),""),"",MAX(OFFSET($N2,-MOD(ROW($N2)+1,3),0,3)))
Another option, not as direct an answer to the question but potentially useful if the number of products changed in future from 3 to something else, would be:
=IF(COUNTIFS(L:L, L2, N:N, ""), "", MAX(IF(L:L=L2, L:L)))
and click Ctrl+Shift+Enter after typing that in (because it's an Array formula, see here, here and here).
The advantage of this approach is that it looks at all rows where the product column is the same (I'm assuming unique products), so no need to limit it to 3 rows per product or have those 3 rows next to each other.
I'm trying to use a VLOOKUP array formula to extract and display multiple columns using one formula.
Excel Formula:
=VLOOKUP(A15,A1:G9,{3,4,5},FALSE)
1 2 3 4 5 6
Transaction ID Payment Date Product Quantity Cost Sales
MVLN195 1/3/2014 Trash Can 1 $14.00 $14.00
XFYR246 1/4/2014 Lawnmower 1 $599.00 $599.00
DWDF167 1/4/2014 Diapers 1 $29.00 $29.00
YNBM339 1/5/2014 Sweater 3 $59.00 $177.00
WTKQ758 1/7/2014 Bike 1 $599.00 $599.00
SFKS527 1/7/2014 Radio 1 $25.00 $25.00
OGWT288 1/8/2014 Bike 1 $599.00 $599.00
TCQN516 1/9/2014 Calender 5 $3.00 $15.00
1 2 3 4
ID Product Quantity Cost
OGWT288 Bike #N/A #N/A
I've tried using the array vlookup formula, but only column 3 comes up. I've tried to press ctrl shift enter as well but still only data from column is pulled not for the other two.
If anyone could be of any assistance would be very helpful.
Thank You
First of all your formula is correct.
Put it in the first column, in your scenario it's A16.
And then select that cell and drag it upto the next 3 cells.
Move your mouse cursor to the top formula bar and click over, and press ctrl+shift+enter
It should work.
Thanks
Put this in the first cell and drag over:
=VLOOKUP($A$15,$A$1:$G$9,COLUMN(C:C),FALSE)
If you really want to array enter then you can use your formula:
Select B15:D15 with B15 active.
Enter the formula in the formula bar.
Hit Ctrl-Shift-Enter to array enter the formula into all three cells at same time.
In my database i have columns with information that are match togheter with a column named MsgNumber this column looks like this:
Where if it´s 1 1 the two rows have some coherent information. 2 and 3 3 3 and 4 4 4 4 and so forh all the rows are aligned that way. My goal is to get the query to order the cells by color as show in the next pictur:
I tried with condition formation but then i needed to do a seperate "report" i need to edit the rows directly in the query. (doing it manually is not an option). Can it be done? Thanks
My data/table that appears in the details section is pulled from SQL.
It essentially is a basic table with Row Names in column 1 and dates going across row 1 with the final column being a summation of the data.
The data is 4 rows long and what I am looking to do is create a field that I can put in the report footer that will display the same information as any one of the individual fields that is displayed in the totaled column (last column) of the table / details section.
For example if the 3rd row totaled 12 (in the details section of the report), I would like to create a standalone field that will display the 12 in the report footer.
The details section looks like a table: the report footer breaks out certain things from the details section. I need something that will allow me to reference the individual numbers in the details for example: only pull in the 18 or only pull in the 11 into its own little field on the report footer. Thanks.
Months 1 2 3 4 total
Jack 3 3 4 5 15
Will 4 7 5 2 18
Mike 1 3 3 5 12
Don 3 5 2 1 11
You need to manipulate by storing in the array and retriving one by one.
To store in array:
Create a formula #Total
Shared Numbervar array x;
x:=x+(total);
total
In report footer write one more formula #display
Shared Numbervar array x;
x[1] // first element in the same way 2,3,4 will give you all elements
Let me know in case any issue.
I have data that looks like this in Excel (like a Gant Chart):
Column A Column B Column C
Step 1 Days to Complete Requires Step First
row 1 1.1 2
row 2 1.2 1
row 3 1.3 1 1.1
row 4 1.4 0
row 5 1.5 1 1.1
You can start steps 1.1, 1.2, and 1.4 right away, but you have to complete step 1.1 before you can start steps 1.3 or 1.5. What can I use to get the TOTAL DAYS TO COMPLETE = 3 result in a cell somewhere in my spreadsheet? I've tried sumif but my column A and column C values do not match adjacent to each other in each row. Plus, if it says step 1.1 in column C twice I only want it to add the value in row 1 column B one time.
Thanks in advance!
If you can use two columns I would do this, first check column C with an if and if it is blank give a cell the value of column B:
=IF(C1 = "", B1, 0)
And then when you have applied this to match with your data you can sum that column in a cell by using:
=SUM(D1:D10)