I have 2 spreadsheets and I'm trying to get all the items that the QTY is not equal to zero.
Can someone help me, please?
Example. If the items in Spreadsheet 1 is not 0 it will transfer to Spreadsheet 2 in one cell.
Spreadsheet 1
*---*----*---*----*
| | ITEMS | QTY|
*---*--------*----*
| 1 | BOOK | 4 |
| 2 | PEN | 4 |
| 3 | tape | 0 |
*---*----*--------*
Spreadsheet 2
+---+---------+
| | A |
+---+---------+
| 1 | BOOK 4 |
| | PEN 4 |
+---+---------+
This formula is the formula.
=JOIN(CHAR(10),QUERY(TRANSPOSE(IMPORTRANGE("URL","SUMMARY!B1:C3")),,2000000))
=TEXTJOIN(CHAR(10), 1, TRANSPOSE(QUERY(TRANSPOSE(QUERY(IMPORTRANGE(
"ID", "Sheet1!A:B"),
"where not Col2 = 0 and Col1 is not null", 0)), , 999^99)))
Related
Let's take this data in a Google sheet:
| Product | Green | Red | Date |
| A | 1 | 0 | 1/1/2020 |
| A | 1 | 0 | 2/1/2020 |
| B | 0 | 1 | 2/25/2020 |
| C | 1 | 0 | 2/28/2020 |
| A | 0 | 1 | 3/1/2020 |
My goal would be to display the sum of Green / Red for each product:
From the beginning of the year,
For the current month.
I created this Google Query to get the results for all the year:
=QUERY(DATA!A:D,"select A, sum(B), sum(C) where D >= date '2020-01-01' and D <= date '2020-12-31' group by A")
I get this result:
| Product | sum Green | sum Red |
| A | 2 | 1 |
| B | 0 | 1 |
| C | 1 | 0 |
And this query for the given month (I simplified the query, but I have a Settings sheet to specify the month to query):
=QUERY(DATA!A:D,"select A, sum(B), sum(C) where D >= date '2020-01-01' and D <= date '2020-01-31' group by A")
And get this result:
| Product | sum Green | sum Red |
| A | 1 | 0 |
Now I'm stuck in joining the two results into one, like this:
| Product | Year sum Green | Year sum Red | Jan sum Green | Jan sum Red |
| A | 2 | 1 | 1 | 0 |
| B | 0 | 1 | | |
| C | 1 | 0 | | |
How can I achieve this ?
Thanks a lot for your help!
try:
=ARRAYFORMULA(IFNA(VLOOKUP(F2:F, QUERY(DATA!A:D,
"select A,sum(B),sum(C)
where month(D)+1 = 1
group by A
label sum(B)'Jan sum Green',sum(C)'Jan sum Red'"), {2,3}, 0)))
With my countifs formula in column C I want to auto-number (running total) all occurrences of an identical string in column A (e.g. Apple or Orange) but only if on the same row where the string appears column B is of a certain type, e.g. if in column B the type is of "fruit" in column C auto number all occurrences of an identical string in column A. For each new string which is of type "fruit" start the numbering all over again.
The outcome should be like this:
+---+-----------+-------+---+--+
| | A | B | C | |
+---+-----------+-------+---+--+
| 1 | Apple | Fruit | 1 | |
| 2 | Apple | Fruit | 2 | |
| 3 | Mercedes | Car | 0 | |
| 4 | Mercedes | Car | 0 | |
| 5 | Orange | Fruit | 1 | |
| 6 | Orange | Fruit | 2 | |
| 7 | Apple | Fruit | 3 | |
+---+-----------+-------+---+--+
The formula in column C:
=COUNTIFS($A1:$A$1;A1;$B1:$B$1;"Fruit")
=COUNTIFS($A$1:$A2;A2;$B$1:$B2;"Fruit")
=COUNTIFS($A$1:$A3;A3;$A$1:$A3;"Fruit")
…and so on…
I want to translate this formula into an array formula and put this into the header so the formula will automatically expand.
No matter what I've tried it won't work.
Any help is truly appreciated!
Here's a link to a sheet: [https://docs.google.com/spreadsheets/d/1lgbuLbTSnyKkqr33NdVuDEv5eoXFwatX1rgeF9YpIks/edit?usp=sharing][1]
={"ARRAYFORMULA HERE"; ARRAYFORMULA(IF(LEN(B2:B), IF(B2:B="Fruit",
MMULT(N(ROW(B2:B)>=TRANSPOSE(ROW(B2:B))), N(B2:B="Fruit"))-
HLOOKUP(0, MMULT(N(ROW(B2:B)>TRANSPOSE(ROW(B2:B))), N(B2:B="Fruit")),
MATCH(VLOOKUP(ROW(B2:B), IF(N(B2:B<>B1:B), ROW(B2:B), ), 1, 1),
VLOOKUP(ROW(B2:B), IF(N(B2:B<>B1:B), ROW(B2:B), ), 1, 1), 0), 0), 0), ))}
demo spreadsheet
=ARRAYFORMULA(IF(LEN(B2:B), IF(B2:B="Fruit",
MMULT(N(ROW(B2:B)>=TRANSPOSE(ROW(B2:B))), N(B2:B="Fruit")), 0), ))
Let's say I have the following in a table :
A | B | desired_output
----------------------------
1 | 10 | 1 | 0
2 | 20 | 7 | 0
3 | 30 | 3 | 0
4 | 20 | 2 | 0
5 | 30 | 5 | 1
I'd like to find a formula for each of the cells in the desired_output column which looks at the max of B1:B5 but only for rows for which A = max(A1:A5)
If that's not clear, I'll try to put it another way :
for all the rows in A1:A5 that are equal to max(A1:A5) // so that's rows 3 and 5
find the one which has the max value on B // so between B3 and B5, that's B5
output 1 for this one, 0 for the other
I'd say there would be a where somewhere if such a function existed, something like = if(B=(max(B1:B5) where A = max(A1:A5)), 1, 0) but I can't find how to do it...
I can do it in two columns with a trick :
A | B | C | D
----------------------------
1 | 10 | 1 | | 0
2 | 20 | 7 | | 0
3 | 30 | 3 | 3 | 0
4 | 20 | 2 | | 0
5 | 30 | 5 | 5 | 1
With Cn = if(An=max(A$1:A$5),Bn,"") and Dn = if(Cn = max(C$1:C$5), 1, 0)
But I still can't find how to do it in one column
For systems without MAXIFS, put this in C1 and fill down.
=--(B1=MAX(INDEX(B$1:B$5-(A$1:A$5<>MAX(A$1:A$5))*1E+99, , )))
=ARRAYFORMULA(IF(LEN(A1:A), IF(IFERROR(VLOOKUP(CONCAT(A1:A&"×", B1:B),
JOIN("×", QUERY(A1:B, "order by A desc, B desc limit 1")), 1, 0), )<>"", 1, 0), ))
or shorter:
=ARRAYFORMULA(IF(A:A<>"",N(A:A&"×"&B:B=JOIN("×",SORTN(A:B,1,,1,0,2,0))),))
=ARRAYFORMULA(IF(A:A<>"",N(A:A&B:B=JOIN(,SORTN(A:B,1,,1,0,2,0))),))
How about the following:
=--AND(A5=MAX($A$1:$A$5),B5=MAXIFS($B$1:$B$5,$A$1:$A$5,MAX($A$1:$A$5)))
I have a table with cells which contain comma-separated multiple values as follows:
+----------+
| Column A |
|----------|
| a, b |
|----------|
| a, b, d |
|----------|
| b, c |
|----------|
| c, d, e |
+----------+
I would like to get a table which counts the number of a, b, ..., e as follows:
+-----------------------+
| Column A | Column B |
|-----------------------|
| a | 2 |
|-----------------------|
| b | 3 |
|-----------------------|
| c | 2 |
|-----------------------|
| d | 2 |
|-----------------------|
| e | 1 |
+-----------------------+
Is there any Google Sheets or LibreOffice Calc spreadsheet formula to do this?
C1: =UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")))
D1: =ARRAYFORMULA(IF(LEN(C:C),COUNTIF(A:A,"=*"&C:C&"*"),))
=QUERY(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")),
"select Col1, count(Col1)
where Col1 is not null
group by Col1
label count(Col1) ''")
={UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,"))),
ARRAYFORMULA(IF(LEN(UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")))),
COUNTIF(A:A,"=*"&UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")))&"*"),))}
Let's take this spreadsheet for example:
ID | StoreName | StoreID | CheckinTime | User
0 | w1 | 1 | 10:00 | user1
1 | w5 | 1 | 10:01 | user2
2 | w2 | 1 | 10:01 | user1
3 | w1 | 1 | 10:01 | user4
4 | w5 | 1 | 10:05 | user1
5 | w3 | 1 | 10:05 | user6
6 | w1 | 1 | 10:05 | user1
7 | w1 | 1 | 10:05 | user1
Is there a way to create a new column/tab/sheet to count all the unique checkins for a store. So let's say; StoreName "w1" is visited by "user1" 3 times and 1 time by "user4". The expected output will be 2 (2 unique visitors for "w1"). This is the output I would like to have:
ID | StoreName | uniqueCheckins
0 | w1 | 2
1 | w2 | 1
2 | w3 | 1
3 | w4 | 0
4 | w5 | 2
To produce the StoreName and uniqueCheckins output columns:
=QUERY(QUERY(B:E,"select B, E, count(C) group by B, E",1),"select Col1, count(Col2) group by Col1 label count(Col2) 'uniqueCheckins'",1)
However this will omit any StoreName that doesn't appear in the raw data (in your example, w4). Would this be OK?
Updated my answer
=({FILTER(SORT(UNIQUE(Index(UNIQUE({B2:B,E2:E}),,1))),SORT(UNIQUE(Index(UNIQUE({B2:B,E2:E}),,1)))<>""),ARRAYFORMULA(COUNTIF(INDEX(UNIQUE({B2:B,E2:E}),,1),"="&FILTER(SORT(UNIQUE(Index(UNIQUE({B2:B,E2:E}),,1))),SORT(UNIQUE(Index(UNIQUE({B2:B,E2:E}),,1)))<>"")))})