Subtraction for two columns with arrayformula and isblank - google-sheets

I have a formula to subtract one column from another: =sum(F5-B5) but i need it in an array and only for non-empty cells. Ive tried the following which doesn't work:
=ARRAYFORMULA(if(isblank(A5:A),"",SUM(F5:F-B5:B)))
Anybody know what the correct formula is?

See if this helps
=ARRAYFORMULA(if(isblank(A5:A),"", F5:F-B5:B))
Sum is an aggregate function where the values of multiple rows are grouped together to form a single summary value. As such, sum can't be iterated over an array.

Related

Reverse order of TEXTJOIN range of cells in a row

Formula I am using in Google Sheets:
=TEXTJOIN(CHAR(10)&CHAR(10),true,C2:2)
I want to reverse the order those cells are joined so that it is always the furthest right cell first.
Please see image below for example of what I am trying to achieve.
Example
I attempted the advice here Reverse order of TEXTJOIN Output but it did not seem to translate for my needs.
Answer
Harun's method is correct, but I hope to provide a simpler and more efficient solution.
The following formula should produce the result you desire:
=TEXTJOIN(CHAR(10)&CHAR(10),true,SORT(TRANSPOSE(C2:2),TRANSPOSE(COLUMN(C2:2)),false))
Explanation
First, the =COLUMN formula is used to obtain column numbers for each column that we want to use =TEXTJOIN on. In this case, that is the range C2:C.
Next, the =TRANSPOSE formula works on both C2:C and =COLUMN(C2:C) to change both from being horizontal arrays to being vertical arrays. This is needed for =SORT to function correctly.
The =SORT function is then used to order the transposed results based on the transposed row numbers. The third argument of =SORT is false because we wish to sort in descending order, from highest column number to lowest.
Finally, everything is combined in the =TEXTJOIN function. Each entry returned by =SORT is joined together with two line breaks using the =CHAR function. The second argument of =TEXTJOIN is true because we want to ignore blank entries.
Functions used:
=TEXTJOIN
=CHAR
=SORT
=TRANSPOSE
=COLUMN
In google-sheet try-
=TEXTJOIN(CHAR(10)&CHAR(10),1,BYROW(SEQUENCE(COUNTA(C2:2),1,COUNTA(C2:2),-1),LAMBDA(x,INDEX(C2:2,1,x))))

Conditional Sumif formula is adding numbers outside of range

I have column U, which should be summing only values with a unique index. So for the highlighted cell, it should only add column T if column A in the same. I can't tell what is wrong with my formula, it is pulling numbers from a different source in the workbook.
My formula:
=if(A3168<>A3169,sumif($A$2:A3168,A3168,$T$2:T3168),"")
Any help with this very much appreciated
it means the value in column A is found further up the sheet. 204 exists in earlier rows.
to truly do just the grouping put this in U2:
=IF(A2<>A3,SUM($T$2:$T2)-SUM($U$1:$U1),"")
And copy down.

Excel/Sheets Consecutive Count Based on Two Conditions (function?)

I have a Google Sheet, and I'm trying to see if it's possible to get a consecutive count outputted in a third column based on the values of two other columns.
My columns are:
Column A: Will have a handful of text values that are "grouped" together. Likely around 30 of the same value, until it changes to another value. In the image above, these are text1, and text2.
Column B: Will have one of 3 values assigned to each value in column A. In the image above, these are id1, id2, id3.
Column C: Will output a consecutive count based on the values of the first two columns. My hope is that if there are multiple ID1,ID2 in consecutive order, they'll repeat that first +1 value; while ID3 is always plus 1 to the count. This is what I am trying to show in column C in the layout image above.
I've hit a wall with trying to accomplish this with various COUNTIF iterations.
Thanks for any help, or any better ideas to accomplish something similar.
(I'm hoping for a formula, but open to being pointed into a direction for a script if that's the only way).
You can try following formula:
=IF(A2=A1;IF(OR(B2="id3";B2<>B1);C1+1;C1);1)
It is also possible to do this as an array formula. I used offset ranges for column B in the first Countifs to check for a change in value but this made it a little awkward to get equal-sized arrays:
=ArrayFormula(if(A2:A="","",
countifs({"";B2:B}<>{B2:B;""},true,{A2:A;""},A2:A,row(A:A),"<"&row(A2:A),{B2:B;""},"<>id3")+
countifs(A2:A,A2:A,row(A2:A),"<="&row(A2:A),B2:B,"=id3")
))

QUERY with AND criteria not returning expected results

I have a QUERY that seems to be treating AND more like OR. In other words, when the value of Col11=TRUE and the value of Col12=7, the results are displayed as though Col12=8. Am I missing something? I've tried adding quotes around the variables, parentheses around the two criteria. Adding spacing around the =. What else is there?
Col11 is only TRUE or FALSE values and Col12 is only numeric values from 1-8.
=QUERY({$A$3:$AJ},"SELECT Col3,Col10 where Col11=TRUE and Col12=8",0)
Here's a link to my sheet. It's buried in a larger formula in AK2
AK6 is a good example. It shows U U. It should only show U. It is treat X6 as though it's value is 8 when it is actually 7.
I believe I worked out what is happening.
You are getting two 'U's because I think your inner array is returning multiple rows for Col3='R2-D2', one row where Col23=TRUE and Col24=8, and then another row where Col27=TRUE and Col28=8.
I'm not positive, but I think the values in AK don't relate specifically to the values in that specific row, but instead relate to an array queried across all of your data rows. So as the outer ArrayFormula works down the column, the inner array (with multiple VLOOKUP/ArrayFormula/Queries) is still a large subset of the whole data range. That's assuming I've understood your complex formula correctly - my apologies if I've misunderstood something.
I've added a Heroes-TEST sheet to your sheet. It only has ten rows, all of the R2-D2 data from your Heroes tab. The columns are collapsed for visibility. See what happens when you highlight all the row data below Row3 and press delete - and then UNDO. The two 'U's in column AK become one, because there is only one row of data to query through now.
Your original formula is in AK2.
Let me know if this has helped.

[google spreadsheets]Joining Multiply Arrays in one formula

I am long looking for solution to a problem that states as this:
I have 3 different ranges in my spreadsheet (lets say they are on different sheets) and I want to join them all on the 4th sheet as one array (like one under another).
And here is my question how can I dot it? I want to then use filter on the given range to make all 3 ranges one sorted range and I want it to enlarge dynamically when I add new rows to one of the source ranges.
I basically tried to use Arrayformulas and query formulas but I didnt found any solution.
Does anybody have any clue or idea how to solve this problem?
Thanks in Advance
volmort
You can use "Embedded Arrays" to achieve this result.
Source Data in:
D6:F9
H6:J9
L6:N9
Formula to aggregate all data ranges:
=FILTER(
{ARRAYFORMULA(D6:F9);ARRAYFORMULA(H6:J9);ARRAYFORMULA(L6:N9)}
, {ARRAYFORMULA(D6:D9);ARRAYFORMULA(H6:H9);ARRAYFORMULA(L6:L9)} <> ""
)
Note: un-populated rows in the source data ranges are "filtered" from the results. An un-populated row is a row with no data in the first column of the range.
If this result is not desired, then a simpler version with ARRAYFORUMULA could be used:
=ARRAYFORMULA(
{ARRAYFORMULA(D6:F9);ARRAYFORMULA(H6:J9);ARRAYFORMULA(L6:N9)}
)
Here is an demonstration of the solution:
https://docs.google.com/spreadsheets/d/1HTyIpaLU0dm89ZY8ka9SI0J2nywnS9QteFY1h9BxdR0/edit?usp=sharing

Resources