Google Sheet ARRAYFORMULA with IF - google-sheets

I am using IF function as below and getting the result, but when I use the same function with ARRAYFORMULA am getting the circulating dependency error:
Without ARRAYFORMULA
=if(isblank(A2),"",IFERROR(IF(A2<>A2,1,B1+1) ))
With ARRAYFORMULA =ARRAYFORMULA(IF(A2:A<>A2:A,1,C1:C+1) )
Further, the result of formula is getting started from cell No. B3, is it possible to get the result started from cell B2 i.e. the cell in which the formula is applied.
Below is the link of the sheet:
https://docs.google.com/spreadsheets/d/1qLjYukNR1E_vgwqeGutQRtg3H7-3eU2heUPHsqQpg90/edit#gid=1713558709.
Any help on above will be greatly appreciated.

I have added a new sheet ("Erik Help") to your sample spreadsheet. This array formula can be found in B1 of that sheet:
=ArrayFormula({"Header"; IF(A2:A="",, ROW(A2:A)-VLOOKUP(ROW(A2:A),{1;FILTER(ROW(A2:A),A2:A="")},1,TRUE))})
You can change the header text as you like.
Here is a plain-English interpretation of the rest of the formula: "If a cell in A2:A is blank, leave it empty; otherwise, subtract the row number of the last empty row from the current non-blank row number. If A2 is non-blank, return 1."

Related

VLOOKUP and INDIRECT, TEXT formula combination

Here is perfectly working formula I have combines with the help of Alistair McEvoy and idfurw:
=HYPERLINK(VLOOKUP(A4,IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/","08/16!A2:Q26"),6), VLOOKUP(A4,IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/","08/16!A2:Q26"),9))
However, I want to update it. Especially this part: "08/16!A2:Q26" from above formula.
How do I re-write formula so that instead of 08/16 would be value from cell A1. Cell A1 contains 08/16 (date format).
This formula gets me data from different unopened google sheet. Unopened spreadsheet contains sheet named 08/16 where data should be extracted from.
I tried this combination but it did not work:
=HYPERLINK(VLOOKUP(A4,IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/",INDIRECT("'"&TEXT($A$1,"MM/dd")&"'!A2:Q26"),6), VLOOKUP(A4,IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/",INDIRECT("'"&TEXT($A$1,"MM/dd")&"'!A2:Q26"),9))
Probably I am doing mistakes with ' and "
So I want to transform "08/16!A2:Q26" into --> "08/16!A2:Q26" but instead of 08/16 will be value from A1 cell. A1 cell value is 08/16
try:
=HYPERLINK(
VLOOKUP(A4,
IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/",
A1&"!A2:Q26"), 6), VLOOKUP(A4,
IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/",
A1&"!A2:Q26"), 9))
or:
=HYPERLINK(
VLOOKUP(A4,
IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/",
TO_TEXT(A1)&"!A2:Q26"), 6), VLOOKUP(A4,
IMPORTRANGE("1RnkAkydjc_wY_iLyyfktUucvi9MHmneVTL9H9J3bgss/",
TO_TEXT(A1)&"!A2:Q26"), 9))

Google Sheet Issue in If function with array formula

Am facing issue in google sheet "if" function as discussed below:
In Cell B4 of the Google Sheets (link is given below) am using below formula and then by draging the formula am getting correct result :
=if(isblank(C4) , B3 , C4 )
But when I use the same formula with ARRAYFORMULA am getting the error. The ARRAYFORMULA is applied in cell A4:
=ARRAYFORMULA(if(isblank(C4:C) , A3:A , C4:C ))
Help on how to fix the error with ARRAYFORMULA in above case would be greatly appreciated.
Below is the link of the sheet:
https://docs.google.com/spreadsheets/d/1fB31msHFWDVv9eweb2H0XJ6zDfpKjxEZG9bpXb36_44/edit#gid=0
Limit the number of rows and apply this formula in third row wherever you need
This is explaned here https://infoinspired.com/google-docs/spreadsheet/fill-blank-cells-with-the-values-above/
The reason is that when lookup find an error in the key, it takes the number immediatly lower. It's why we divide the row by 0 when the cell is empty.
=ArrayFormula(lookup(row(C3:C),row(C3:C)/if(C3:C<>"",1,0),C3:C))
To make it work go to
"File" --> "Spreadsheet settings" --> "Calculation" --> "Iterative calculation"
There you press On and nothing else.
It now works.
Good read: Choose how often formulas calculate

Using array formula and countif to lookup based on specific cells

I'm trying to embed a countif into an array formula in Google Sheets. I'm using the countif command to count the number of cells on another page with a given text string, stored in column B. Column B just contains a list of titles. The concatenate portion does a general keyword lookup.
Here is the formula that does not work. It just returns a 0 in each cell, which tells me the countif statement is failing.
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*"))),""))
If I pull out the countif statement, it works fine by itself.
=COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*")))
I have even tried referencing B2:B in place of the B2 cell reference, but that does not work. What did I do wrong in the array formula statement?
Have you tried using & instead of the CONCATENATE function and referencing to B2:B in place of only B2?
The formula should look like this:
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,("*" & B2:B & "*")),""))
It works for me.
This is my 'Registrations' sheet:
And this is the sheet where the formula is written:

Formula to give itemized sum

I have the following sheet (link). What formula would yield the itemized sums in B2, C2, and D2?
To calculate the value in B2, the formula should check cells B5:B10 and sum the corresponding values from A5:A10 for non-blank cells. Hence: 30+45+30=105.
I have tried ARRAYFORMULA(IF(B5:B10 != ""), sum(A5:A10)) which results in Formula parse error.
Considering that the numbers in column B are not to used (thats what i figured out from your example).
you can use sumIf:
=SUMIF(B5:B10,">0",A5:A10)
so this will check if the cell in column B is greater than 0, then it will add its corresponding value from column A.
please note that if you put a character in the B column the SUMIF will not consider it because we are using ">0" as criterion, instead use ISBLANK.
hope it helps.

Sum values based on row value and column header

We have a Google Sheet doc which contains a date column with each date as a row value, and also multiple columns (some of which have the same name) and we want to sum the values in the cells where the row is a specific date, and the column has a specific header. For example where the date is 01/03/2017 we want to sum all the values which have the column header "X" on that date. Can this be done?
Yes it can be done
=SUMIF($C$3:$J$3,"X",OFFSET(C3:J3,MATCH(B1,B4:B15,0)+3,0))
Broken down
=sumif($C$3:$J$3 [<-header row with X],"X" [<-what we're looking for],C3:J3 [<-row to sum])
the formula above will sum the header row if there is an "X" (not very useful)
I used offset(C3:J3,[row number],0) with the header row range to push it down to the row matching 01/03/2017
To get the row number of 01/03/2017 I used Match() and put 01/02/2017 in cell B1
MATCH(B1,B4:B15 [range of dates] ,0)
I add 3 becuase my range starts at 4
You can hard code the date into the formula by replacing B1 with
DATEVALUE("01/03/2017")
I've not tried this in Google Sheets as I don't have access at the moment but it works in Excel and I'll try it in Sheets later.
Here's the formula that you can paste into A2 on your sheet "Sum of Data"
=SUMIF(Data!$B$1:$J$1,B$1,OFFSET(Data!$B$1:$J$1,MATCH($A2,Data!$A$2:$A,0),0))
It's all about changing the original formula to match your data and also locking the ranges correctly with the $ so that it will autofill down and across without breaking.
Use INDEX to peel off the appropriate column for SUMIF.
=SUMIF(A:A, G4, INDEX(A:E, 0, MATCH(H4, 1:1, 0)))
Considering a sheet where:
Cell B1 contains the date of interest (e.g. 01/03/2017)
Cell B2 contains the header of interest (e.g. X)
Cell B3 returns the sum of interest (values of all columns with header "X" on 01/03/2017)
Row 4 contains the headers to be evaluated (e.g. "Date", "A", "B", "X", "C", "X", "D")
Subsequent rows contain the actual data (e.g. dates in column A and data in columns B:G)
Refer to the image on the link below for details:
Example with cells of interest highlighted in yellow
The following formula should return the expected result:
=SUMIF(4:4,B2,INDEX(A:G,MATCH(B1,A:A,0),0))
I used Google Sheets in Portuguese. So, the formula actually tested was:
=SOMASE(4:4;B2;ÍNDICE(A:G;CORRESP(B1;A:A;0);0))
I hope that was usefeul.

Resources