CONCATENATE cells in the column with ARRAYFORMULA - google-sheets

CONCATENATE cells in the column which separated by empty cells using ARRAYFORMULA. I have an idea but am not sure it is right. First of all get row number of first and last names for each day. Combine them in formula and finally put that formula to ARRAYFORMULA.
D2= =ARRAYFORMULA(IF(B2:B<>"",ROW(B2:B)+1,""))
E2= =ARRAYFORMULA(IF(C2:C<>"",IF(C3:C="",ROW(B2:B),""),""))
So the question is how to get the row number of the last name for each day in the same row as a day and how to combine this number to a formula which can be compatible with ARRAYFORMULA.
Example:

To get to the result (with steps in between) try (in a empty column in row 2)
=ArrayFormula(If(right(B2:B, 3)="day", offset(B2:B, 1,1)&", "&offset(B2:B, 2,1),))
and see if that works ?

Related

Sum every n columns starting at the 1st column in the range

In Excel/Google Sheets I have found how to sum every N columns on websites such as https://exceljet.net/formula/fixed-value-every-n-columns, but the problem is, from what I can see is that it starts at N column each time. I need something that starts from column 1 and then counts every N columns. like the following:
I need to do this with a formula and not a script.
With Google-Sheets, try:
Formula in M2:
=SUM(QUERY(TRANSPOSE(A2:J2),"Skipping "&L2))
Or, a single dynamic array formula (without dragging):
=INDEX(MMULT(A2:J4*(MOD(COLUMN(A2:J4),L2:L4)=1),SEQUENCE(10,1,1,0)))
Or, more dynamic:
=INDEX(MMULT(A2:J4*(MOD(COLUMN(A2:J4),L2:L4)=1),SEQUENCE(COLUMNS(A2:J4),1,1,0)))
Note: The latter would also work in Excel with slight modifications.
Google sheets formula:
=SUM(FILTER(A2:J2, MOD(A2:J2, L2)=1))
then drag to other cells
or use this array version:
Array version:
=INDEX(TRANSPOSE(MMULT(A2:J4,TRANSPOSE(COLUMN(A2:J4)^0 *
N(MOD(COLUMN(A2:J4), L2:L4)=1)))), ,1)
If you want the cells that were added to be automatically highlighted.
Conditional formatting used on A2:J:
=MOD(COLUMN(), $L2)=1
In M2:
=SUMPRODUCT(A2:J2,N(MOD(SEQUENCE(,COLUMNS(A2:J2),0),L2)=0))
and copied down.
Try this formula on column M:
=SUM((sumif(ArrayFormula(mod((COLUMN(B2:J2)-COLUMN(B2)+1),L2)),0,B2:J2))+A2)
Here's the result on Column M.
Just to break down the code sumif(ArrayFormula(mod((COLUMN(B2:J2)-COLUMN(B2)+1),L2)),0,B2:J2) does the actual calculation with the number of intervals set on Column L but take note that I started at the 2nd column so the range here does not include the first column. The result from this is at the Column O highlighted red as you can see in the screenshot.
At the Column M is the actual solution where I only added the first column by using SUM on top of the previous formula.
I hope my explanation is clear.
Just copy/drag the formula down to each row and it should work.
Reference: How to Sum Every Nth Row or Column in Google Sheets Using SUMIF

Array formula with filter and index values depending on countif

I need an array formula only in column Date_2 with results like on screenshot and that will
insert last day of month depending on Date_0 (if bunch of Color&Fruit&Meal doesn't repeat in table)
insert first minimum date of column Date_1 (if bunch of Color&Fruit&Meal repeats first time) - 1
insert second minimum date of column Date_1 (if bunch of Color&Fruit&Meal repeats second time) - 1
and so on...
Is is possible to solve it with array formula?
I've tried but I can't..
=ArrayFormula(IF(A2:A="","",IF(COUNTIF(B2:B&C2:C&D2:D,B2:B&C2:C&D2:D)>1,INDEX(FILTER(B2:E,E2:E<>""),1,4),EOMONTH(A2:A,0))))
Google Sheets
I'm not quite sure what you need for Date_1 but try this arrayformula in cell F2 for Date_2:
=ARRAYFORMULA({"Date_2";if(IF(B2:B&""&C2:C&""&D2:D<>"",if(A2:A<>"",COUNTIFS(B2:B&"|"&C2:C&"|"&D2:D,B2:B&"|"&C2:C&"|"&D2:D,ROW(A2:A),"<="&ROW(A2:A)),),)=1,eomonth(A2:A,0),)})
I've added a duplicate sheet ("Erik Help") with the following formula in F1:
=ArrayFormula({"Date_2";IF(A2:A="",,IFERROR(VLOOKUP(B2:B&C2:C&D2:D&TEXT(COUNTIFS(B2:B&C2:C&D2:D,B2:B&C2:C&D2:D,ROW(A2:A),"<="&ROW(A2:A))+1,"000"),{B2:B&C2:C&D2:D&TEXT(COUNTIFS(B2:B&C2:C&D2:D,B2:B&C2:C&D2:D,ROW(A2:A),"<="&ROW(A2:A)),"000"),E2:E},2,FALSE)-1,EOMONTH(A2:A,0)))})
This formula creates the header (which you can change within the formula) and all results for Column F.
To lookup the "next instance of the group if there is one," I just wrote the formula to VLOOKUP that grouping plus a text rendering of the COUNTIFS-as-of-that-row-plus-1 for that grouping within a virtual array of each-grouping-plus-unique-count-thus-far in one column and the E2:E data in the next column. For instance, for Row 2, the formula VLOOKUPs redapplepie002
(002 being the text rendition of 001, which is the count of redapplepie as of row 2).

Arrayformula not populating all other rows when using index+match

Sample data: https://docs.google.com/spreadsheets/d/10H7hToEek7XxXpPiAtlj6n58db_83Njdaxxspk4pIO8/edit?usp=sharing
Im trying to populate the 1st column of sheet 1 based on the data on sheet 2. VLOOKUP wouldnt work because im comparing the 2nd column of sheet 1 to the 2nd column of sheet 2 and vlookup will only allow it if im comparing to the 1st column of sheet 2. I tried index+match and it worked for 1 row but when I try to use arrayformula to populate all rows, it never runs for all the other rows.
Here is the index+match formula im using: INDEX(Sheet2!A2:A,MATCH(B2:B,Sheet2!B2:B,0))
Here is the formula I use with arrayformula:
=ARRAYFORMULA(INDEX(Sheet2!A2:A,MATCH(B2:B,Sheet2!B2:B,0)))
How do I make this run for all rows and if this won't work is there a better way to go about this?
per slippy101: =ArrayFormula(VLOOKUP(FILTER(B2:B,B2:B<>""),{Sheet2!B:B,Sheet2!A:A},2))
per Dazrin: =ARRAYFORMULA(IF(B2:B="",,VLOOKUP(B2:B, {Sheet2!B2:B,Sheet2!A2:A}, 2, FALSE)))
Both formula works, the problem arises because INDEX doesn't work with ARRAYFORMULA pointed out by Dazrin as well.

Transpose unique data from column into 1 row in new sheet with more than 1 separator columns with headers

While searching for a function to use, I found the below formula to adapt from.
=TRANSPOSE(ArrayFormula(TRIM(SPLIT(QUERY(A1:A30&"|"&rept("|",1),,2^99),"|",1,0))))
What has worked so far is the use of the below formula but
I can't seem to change it to more than 1 separator column.
={(ArrayFormula(TRIM(SPLIT(QUERY(UNIQUE(A2:A)&"|"&rept("|",1),,3^99),"|",1,0))))}
Also, is it possible to add headers to the currently empty separator columns in the sequence of example: "qty","expiry","available qty" before the next column and repeat again "qty","expiry","available qty"
Test spreadsheet in at cell I1 (Join function doesn't work as there's a limit):
https://docs.google.com/spreadsheets/d/1w64R9QR_pAvdGy7IZLsHFvhIYIGL7lqsl_vFXrqsQMc/edit#gid=799170483
Please use the following formula and adjust ranges to your needs:
={(ArrayFormula(TRIM(SPLIT(QUERY(UNIQUE(A2:A)&"|qty|expiry|available qty"&rept("|",1),,2^99),"|",1,0))))}
Functions used:
ArrayFormula
TRIM
SPLIT
QUERY
UNIQUE

Arrayformula sum one column until this row

I'm trying to make an array formula which sums up all the rows until this row.
For clarification column a will be the input and column b would be the output. I'm looking for a way to do this with an arrayformula.
a1:1 b1:1a2:2 b2:3a3:5 b3:8a4:3 b4:11
I tried to use =ARRAYFORMULA(SUM(INDIRECT("F1:"&ADDRESS(ROW(),COLUMN(F2:F))))) but this doesn't work.
How about
=arrayformula(sumif(row(A1:A4),"<="&row(A1:A4),A1:A4))
The sumif is evaluated separately for each value in the criteria part so:
In the first row of the output array you have
=sumif(row(A1:A4),"<=1",A1:A4)
giving you just the first row of column A.
In the second row of the output array you have
=sumif(row(A1:A4),"<=2",A1:A4)
giving you the sum of the first 2 rows and so on.
Since OP changed the question with a clarification, A different answer is submitted below:
B1:
=ARRAYFORMULA(MMULT(transpose(A1:A5)*--IF(row(1:5),COLUMN(A:E)<=row(1:5)),ROW(1:5)^0))

Resources