I have multiple cells that each contain two numbers separated by a "/"
For example:
A1 = 10/2
A2 = 5/4
A3 = 8/1
A4 = 13/1
in A5, I would like to summarize everything on the left side of the "/" and on the right side of the "/". So A5 should have the output: 36/8
How do I do this?
Thanks in advance!
Try below formula-
=SUM(INDEX(SPLIT(A1:A4,"/"),,1)) & "/" & SUM(INDEX(SPLIT(A1:A4,"/"),,2))
Also can try-
=JOIN("/",QUERY(INDEX(SPLIT(A1:A4,"/")),"select sum(Col1), sum(Col2) label sum(Col1) '', sum(Col2) ''"))
try:
=INDEX(JOIN("/", MMULT(TRANSPOSE(SPLIT(A1:A4, "/")), {1;1;1;1})))
Alternatively:
Formula in B1:
=JOIN("/",INDEX(QUERY(SPLIT(A1:A4,"/"),"select Sum(Col1), Sum(Col2)"),2))
Related
I want to use a formula to find the highest N values in each group in a Google Spread Sheets.
I tried this formula from infoinspired.com (credit to Prashanth):
=ArrayFormula(QUERY({SORT(A2:B;1;true;2;false);IFERROR(row(A2:A)-match(query(SORT(A2:B;1;true;2;false);"Select Col1");query(SORT(A2:B;1;true;2;false);"Select Col1");0))};"Select Col1,Col2 where Col3<3"))
But all it return is an Array_Literal error:
This is what I expect:
What is wrong with it?
You have to put a comma, not a semi colon before IFERROR. It's creating two columns, one twice larger than the other instead of three columns ;)
=ArrayFormula(QUERY({SORT(A2:B,1,true,2,false),IFERROR(row(A2:A)-match(query(SORT(A2:B,1,true,2,false),"Select Col1"),query(SORT(A2:B,1,true,2,false),"Select Col1"),0))},"Select Col1,Col2 where Col3<3"))
alternative formula:
=QUERY(SORT({{A2:B}\MAP(A2:A;B2:B;lambda(ax;bx;IFERROR(Rank(bx;Filter(B$2:$B;A$2:$A=ax);0);IFERROR(1/0))))};1;0;3;1);"Select Col1, Col2 Where Col3<3")
-
I'm pretty new with ArrayFormula, have been trying but sometime the formula works, sometimes does not. What I'm trying to do is the combination of ArrayFormula, Countif for searching partial text.
As shown in the worksheet below, there are 10 subjects (column A), each subject has at least one of 4 samples (A,B,C,D) summarized as a string (column B). What I'm trying to do is to find which subject has sample A or B or C or D.
I have tried single formula for each sample, eg cell D3
=IF(COUNTIF($B3,"*"&$D$2&"*")>0,$A3,"")
it returns the correct results. However, when I try arrayformula in cell I3,
=arrayformula(IF(COUNTIF($B3:B,"*"&$D$2&"*")>0,$A3:A,""))
The answers are weird. For example: Subjects (Gamma, Zeta, Eta, Theta) who don't have the sample "A" are shown to have sample "A". And this applies to sample B,C,D too
Not sure what went wrong in here. Here is the link to the worksheet
I wouldn't use Countifs or an array formula. Use filter instead. Put this formula in cell i3.
=Filter(if(REGEXMATCH(B3:B,$D$2),A3:A,""),B3:B<>"")
try:
=INDEX(QUERY(IFERROR(TRIM(SPLIT(FLATTEN(IF(IFERROR(SPLIT(B3:B, ","))="",,
SPLIT(B3:B, ",")&"×"&A3:A)), "×"))),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"))
or use in row 2 if you want to sort it as in your example:
=INDEX(IFNA(VLOOKUP(A2:A, QUERY(IFERROR(TRIM(SPLIT(FLATTEN(
IF(IFERROR(SPLIT(B3:B, ","))="",,SPLIT(B3:B, ",")&"×"&A3:A)), "×"))),
"select Col2,max(Col2) where Col2 is not null group by Col2
pivot Col1 label Col2'Subjects'"), {2,3,4,5}, 0)))
You can accomplish all four columns of results with a single formula.
Delete all formulas from I3:L3.
Place the following formula into I3:
=ArrayFormula(IF(REGEXMATCH(B3:B,I2:L2),A3:A,))
In plain speech, this read "If anything in B3:B matches a value found in I2:L2, return A3:A in the matching columns(s) at the matching row(s); if not, return null."
This is a simplified version of my data.
I want to calculate the "Whole Tax" row Automatically. I mean I'm looking for any special google sheets formula that can search for those records that are equal to "TAX" and SUM on the values in corresponding month.
In google sheet QUERY() function is really faster and more scalable. You can use wildcard character to ignore leading and trailing spaces. Try below formula.
=SUM(QUERY($A$3:$D$16,"SELECT B WHERE LOWER(A) LIKE '%tax%'"))
On single go get sum of all columns. As per my screenshot put below formula to B17 cell.
=QUERY($A$3:$D$16,"SELECT SUM(B), SUM(C), SUM(D) WHERE LOWER(A) LIKE '%tax%' LABEL SUM(B) '', SUM(C) '', SUM(D) ''")
You should have posted a spreadsheet instead of an image to find out your locale. Try in B17, assuming TAX is not preceded by white spaces
=SUMPRODUCT($A$2:$A$16="TAX",B2:B16)
Consider placing sums at the top of each column so you can select cells using A2:A for rest of column.
Anyhow, use =SUMIF($A$1:$A$15, "*tax", B1:B15) for strings that end in tax, case-insensitive. The wildcard selectors are * for wildcard strings and ? for wildcard characters. Use ~ to escape.
Following on from Harun24HR, here is a more flexible formula in which you do not have to designate each column
=QUERY({A3:D16},"SELECT SUM(Col"&arrayformula(textjoin("),SUM(Col",,COLUMN(B3:D)))&") WHERE LOWER(Col1) LIKE '%tax%' LABEL SUM(Col"&arrayformula(textjoin(")'', SUM(Col",,COLUMN(B3:D)))&") '' ")
I'm trying to get unique values by using this formula:
=UNIQUE(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/here goes link","Income!2:8000"),"Select Col15,Col16, Col26 where Col3=" & "'" & B2 & "'"))
And I'm getting the result that I need. The only problem is that I'd like to add an additional condition to it and have no idea how to do it.
I'd like this formula to filter values not only based on Col3 but based on another one, for example, Col3 = B2 and Col2 = A2.
Does anyone have any idea how to do it?
Thank you in advance!
Update: based on the sheet and the data format you have shared, this formula should work:
=UNIQUE(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1pXFIWzeHcJPQJtjUqOdgi2FusNGEUoeGlA5rLGNuKLQ/edit#gid=0","data!2:500"),"Select Col15, Col16, Col26 where Col3 = '"&B2&"' and Col2 = date'"&TEXT(DATEVALUE(A2), "yyyy-mm-dd")&"'")
You can use and with where to check for multiple conditions.
=UNIQUE(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/here goes link","Income!2:8000"),"Select Col15, Col16, Col26 where Col3 = '"&B2&"' and Col2 = '"&A2&"'"))
I have tried to use a COUNTUNIQUE function within ArrayFormula in cell 'A2' to get a result in the range like a column B that I've set a function cell by cell. But it returns only a single value. This is my formula in cell 'A2':
=ArrayFormula(COUNTUNIQUE(D2:D7,E2:E7,F2:F7,G2:G7,H2:H7))
Any help will be greatly appreciated!
This problem has interested me for a while. Basically, the solution from #player0 seems obvious to me. But it is difficult to read.
Perhaps using combined arrays and implicit endings search is more appropriate:
=INDEX(
COUNTIF(
UNIQUE(FLATTEN(
{"" & ROW(C2:Z), ROW(C2:Z) & "-" & C2:Z}
)),
ROW(C2:Z7) & "-*"
) - 1
)
you can do it like this:
=ARRAYFORMULA(QUERY(UNIQUE(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(D2:K<>"", "♦"&ROW(A2:A)&"♥"&D2:K, )),,999^99)),,999^99), "♦")), "♥"))),
"select count(Col1) where Col1 is not null group by Col1 label count(Col1)''", 0))
or like this:
=ARRAYFORMULA({
COUNTUNIQUE(D2:H2);
COUNTUNIQUE(D3:H3);
COUNTUNIQUE(D4:H4);
COUNTUNIQUE(D5:H5);
COUNTUNIQUE(D6:H6);
COUNTUNIQUE(D7:H7)})