Summation formula needed - google-sheets

I need help with creating a formula in Google Sheets for the sum of:
x*(0.95^1+0.95^2+0.95^3+...+0.95^n)
where x is a constant, and n is a positive integer. The formula must fit in one cell.

=x*SERIESSUM(.95,1,1,{1,1,1,1,1})
While there very possibly a ready-made statistical or financial worksheet function for this, you seem to be happy with the results from this formula offered in another answer.
You just need to generate the array n times with n being the value from a cell on the worksheet.
INDEX(ROW(1:4), , ) returns a result of {1, 2, 3, 4} as a true array.
To convert {1, 2, 3, 4} to {1, 1, 1, 1} use a SIGN function 'wrapper' around the row numbers.
=INDEX(SIGN(ROW(1:4)), , ) 'returns {1, 1, 1, 1} as a true array
To vary the length of the array, use INDIRECT to build the ROW reference. With 4 in C10, this returns the same result.
=INDEX(SIGN(ROW(INDIRECT("1:"&C10))),,) 'returns {1, 1, 1, 1} as a true array
'proof
=SUM(INDEX(SIGN(ROW(INDIRECT("1:"&C10))),,)) 'returns 4
Put that together with the rest of the formula as a standard formula with INDEX in array mode.
=B10*SERIESSUM(0.95, 1, 1, INDEX(SIGN(ROW(INDIRECT("1:"&C10))),,))
If you don't wish to use INDEX in its array mode, you can dispense with it and add an ARRAYFORMULA wrapper instead.
enter image description here

Please try:
=x*SERIESSUM(.95,1,1,{1,1,1,1,1})
where the array has n 1s (5 for example).

Related

Countifs with array formula to collect data

I have a raw data that contains types of defect (EC,VC,BC,NC).
first type of defect calculation (EC,VC,BC).
For example if i want to collect the EC defects, I will collect all the rows that contain EC=0 & if the EC is score down to 0 twice in the same row it will count as 1 EC only in this raw.
Same goes for VC & BC.
Second Type of defect calculation (NC)
Same calculation of the above but if the NC defect was repeated on the same row it will be summed.
I have the headers containing VC,EC,BC,NC above each column containing the score.
What i need here to calculate each raw containing defects.
I tried the below formula for VC,EC,BC.
=ARRAYFORMULA(IF(ROW(E2:E)=2,"EC",IF(LEN(E2:E)=0,IFERROR(1/0),IF(COUNTIFS($E$1:$BH$1,"EC",$E:$BH,0)>=1,1,0))))
The formula is working without the array formula, but will be hard to drag each time the data is updated.
Also, Tried the below for NC.
=ARRAYFORMULA(IF(ROW(H2:H)=2,"NC",IF(LEN(H2:H)=0,IFERROR(1/0),COUNTIFS($E$1:$BH$1,"NC",$E:$BH,0))))
Sample Sheet: Test Sheet
={"EC"; ARRAYFORMULA(IF(LEN(TRIM(FLATTEN(QUERY(TRANSPOSE(IF(FILTER(
INDIRECT("E3:"&ADDRESS(MAX((E:Z<>"")*(ROW(A:A))), COLUMNS(1:1))),
E1:1="EC")=0, 1, )),,9^9))))>0, 1, 0))}
={"VC"; ARRAYFORMULA(IF(LEN(TRIM(FLATTEN(QUERY(TRANSPOSE(IF(FILTER(
INDIRECT("E3:"&ADDRESS(MAX((E:Z<>"")*(ROW(A:A))), COLUMNS(1:1))),
E1:1="VC")=0, 1, )),,9^9))))>0, 1, 0))}
={"BC"; ARRAYFORMULA(IF(LEN(TRIM(FLATTEN(QUERY(TRANSPOSE(IF(FILTER(
INDIRECT("E3:"&ADDRESS(MAX((E:Z<>"")*(ROW(A:A))), COLUMNS(1:1))),
E1:1="BC")=0, 1, )),,9^9))))>0, 1, 0))}
={"NC"; ARRAYFORMULA(MMULT(IF(FILTER(
INDIRECT("E3:"&ADDRESS(MAX((E:Z<>"")*(ROW(A:A))), COLUMNS(1:1))),
E1:1="NC")=0, 1, 0), SEQUENCE(COUNTIF(E1:1, "NC"))^0))}

VLookup search for columns concatenation

I have a search term which spans into 3 columns.
text_A, text_B, text_C
I'm trying to find the A column value for a row which forms almost the same values:
text_A, text_B, text that starts with text_C
I get no result even before handling the search of starts with text_C, even though I expected to get one.
Any tip on how to change this?
=VLOOKUP(I10:I&"^"&J10:J, C10:C&"^"&D10:D, 1, FALSE)
try:
=INDEX(IFNA(VLOOKUP(I10:I&"^"&J10:J, {C10:C&"^"&D10:D, E10:E}, 2, 0)))
update
=ARRAYFORMULA(IFNA(VLOOKUP(I10:I&"×"&J10:J&"×"&K10:K,
{C10:C&"×"&D10:D&"×"&IFERROR(REGEXEXTRACT(E10:E&"",
TEXTJOIN("|", 1, SORT(K10:K, 1, 0)))), B10:B}, 2, 0)))

Get the Sum of the top X values from a single Row (Sheets)

I struggling to get the sum total of the top X values for a Row.
Let say top 3 in this case.
A
B
C
D
E
1
john
1
4
3
2
2
Mary
4
5
1
2
So the total of the top 3 values would be
name
Total
John
9
Mary
11
I can get a single LARGE number but can't figure out how to get the top 5 in the row (and then sum). Most examples have the values in COLS but my data is in ROWS
Answer:
Sum of top 5 in a row:
=ARRAYFORMULA(SUM(IFERROR(LARGE(A1:1, {1, 2, 3, 4, 5}), 0))
Rundown of this formula:
Use the array notation to denote the first, second, third, fourth and fifth highest in the row with {1, 2, 3, 4, 5}
Set this array as the n parameter for a LARGE formula, with the row as the range parameter
If the LARGE throws an error for whatever reason, return the value 0 for that value of n
SUM all answers
Wrap inside an ARRAYFORMULA so that LARGE gets all array values and not just the first.
References:
Using arrays in Google Sheets - Docs Editors Help
LARGE - Docs Editors Help
IFERROR - Docs Editors Help
SUM - Docs Editors Help
ARRAYFORMULA - Docs Editors Help

Output multi column instead of multi row

I have had the following question, that was answered here:
Google Sheets Formula: Sum if Substring in range of cells
The final formula works and gives me a row for each month:
The question is: Once the formula is executed, it returns multiple rows- can I get the results in multiple columns? I mean, the three return values next to each other, instead of below each other?
It's the TRANSPOSE() function. To answer the original formula:
=TRANSPOSE(ARRAYFORMULA(
SUMIF(
MID(A:A, 4, 2),
UNIQUE(MID(FILTER(A3:A, A3:A <> ""), 4, 2)),
B:B
)
))
This will deliver the results in columns instead of rows.

Google Sheets: Listing and counting unique values from multiple cells

I'm looking to list and count unique values from multiple cells. The practical application is to list and count the scenes in a movie that a particular character appears in.
I'm using the following array formula to list the scenes from the data table:
=ArrayFormula(TEXTJOIN(", ",TRUE,IF($B$11:$B$64=E13,$A$11:$A$64,"")))
It will returns something like this (these are the scene numbers):
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4
But I want it to return:
2,3,4
Then to count the unique values I used the following formula:
COUNTUNIQUE(SPLIT(F13,", ",0))
But the problem here is that it returns "1" even when the array formula correctly returns no value (i.e. the character didn't appear in any scene)
Here is the Google Sheet so you can see things in context:
https://docs.google.com/spreadsheets/d/1dwrORFJ508duRP1no7258dqLemujkOjpvA3XmolqtsU/edit?usp=sharing
Any help will be greatly appreciated!
F11:
=ARRAYFORMULA(TEXTJOIN(",",1,UNIQUE(IF(E11=B$11:B,A$11:A,))))
=COUNT(SPLIT(F11,","))
Use UNIQUE() to find unique values before joining them
SPLIT parameter 1 can't be empty, which gives a #VALUE error,Which is counted as 1 with COUNTUNIQUE.Use IFERROR to mask it.(Since we already have unique values, COUNT is simpler)

Resources