So I have a large data set of products, (in my case, boxes of floor tiles).
each product has five related columns:
The product name ("Stone-Grey", "Cubic-Dark", etc)
The product series ("P-26", "D-25-A", "26-A-C", etc)
The warehouse where the product is stored ("P1", "D4", "A3", etc)
The shelf number where the product is stored ("1", "17", "25", etc)
The number of units within each box
There is quite a mess with the stock, and I need to rearrange some of it.
The problem is that the stock is dynamic, and I need my lists to be dynamic also.
My end goal is to list all the boxes with less than X items in the box and match all similar products (similar product = has the same name and series), and where exactly it's located (warehouse and shelf).
I've succeeded in creating the dynamic list of lacking boxes using The QUERY function, and also in creating a formula for the second part (matching all similar products, and their location).
The problem is it's a drag-down formula, and I need a dynamic formula, based on the size of the former list.
The first list is pretty much straight forward:
=Arrayformula(Concat(QUERY('Tiles_stock'!$A$4:AC$216,"Select A Where R < 0.13"),(Concat("_",QUERY('Tiles_stock'!$A$4:AC$216,"Select C Where R < 0.13")))))
The formula returns the warehouse and the shelf, matched together.
Now the tricky part, the second formula is:
=Textjoin(" , ",True, Arrayformula(Concat(QUERY('Tiles_stock'!$A$4:X$216,"Select A where N contains '"& O4 &"' AND O contains '"& P4 &"' AND R > 0.13 "),(Concat("_",QUERY('Tiles_stock'!$A$4:X$216,"Select C where N contains '"& O4 &"' AND O contains '"& P4 &"' AND R > 0.13 "))))))
Which works fine, but forces me to drag it down or up each time the first list has changed (as I said, it's a stock, and it's dynamic).
Here's an image of what I'm basically trying to achieve:
https://drive.google.com/file/d/1UIim9oFRyOqYZpzcg9VsYvzuffP6sQ7F/view?usp=sharing
Here's a link to the spreadsheet:
https://docs.google.com/spreadsheets/d/13q7EBz18z6t_iMVTT-M7fzcPjtdYligYjz_m90h_z3A/edit?usp=sharing
list all the boxes with less than X items in the box and match all similar products (similar product = has the same name and series)...
=ARRAYFORMULA(QUERY({QUERY(
QUERY(QUERY({A2:A&" "&B2:B, C2:C&"_"&D2:D, E2:E},
"select Col1,Col2 where Col3 >= 10", 0),
"select Col1, count(Col1) group by Col1 pivot Col2", 0),
"select Col1", 0),
REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IF(ISNUMBER(
QUERY(QUERY({A2:A&" "&B2:B, C2:C&"_"&D2:D, E2:E},
"select Col1,Col2 where Col3 >= 10", 0),
"select count(Col1) group by Col1 pivot Col2", 0)),
QUERY(QUERY({A2:A&" "&B2:B, C2:C&"_"&D2:D, E2:E},
"select Col1,Col2 where Col3 >= 10", 0),
"select count(Col1) group by Col1 pivot Col2 limit 0", 0)&",", )),,999^99))), ",$", )},
"offset 1", 0))
Related
I have the following data and the work-in-progress formula
=ARRAYFORMULA({unique(A2:A);flatten(UNIQUE(filter(C2:C, A2:A=A2))&": "&countif(filter(C2:C, A2:A=A2),UNIQUE(filter(C2:C, A2:A=A2))))})
How can I go about creating the DESIRED OUTPUT from the dataset?
Google Sheet link: https://docs.google.com/spreadsheets/d/1F-ZRe0hgFWdb318xHtiIGmR-RvxSgv518k9wCUBfCm0/edit?usp=sharing
The query() function lets you get those results, although they will be tabulated in a format that is different from what you requested:
=query(A1:C, "select A, count(A) where C is not null group by A pivot C", 1)
use:
=INDEX(LAMBDA(x, y,
QUERY(FLATTEN({SORT(UNIQUE(FILTER({IFERROR(x/0, ""), x}, x<>""))),
IF(QUERY(y, "offset 1", )="",,INDEX(y, 1)&": "&QUERY(y, "offset 1", ))}),
"where Col1 is not null offset 1", ))
(A2:A, QUERY(A2:C, "select count(A) where C is not null group by A pivot C")))
Columns D:H show my initial info, where two workstreams (Column D) have different issues occur (Column F:H). These issues fall under one of three categories, under Columns A:B. I want the chart to show the count of the category each issues falls under, making sure it's also showing that it's within a certain workstream.
what i was working with so far is below to match issues to the three categories
=INDEX(A:B, MATCH(F1, A:A, 0), 2)
and below to count the times a value is within the workstream group (A or B).
=countif(flatten(filter(F:H,D:D="A")),"one")
How can I combine these two?
https://docs.google.com/spreadsheets/d/1hs-Srt-qdOR44V_rmvKF-rC5DThRrQrrCfiA_jAvnH0/edit?usp=sharing
delete J:M range and use in D1:
=INDEX({QUERY(SPLIT(FLATTEN(D1:D9&"×"&VLOOKUP(F1:H9, A1:B12, 2, 0)), "×"),
"select Col1,count(Col1) where Col2 is not null
group by Col1 pivot Col2 label Col1'workstream'"); "TOTAL",
TRANSPOSE(MMULT(1*QUERY(
QUERY(SPLIT(FLATTEN(D1:D9&"×"&VLOOKUP(F1:H9, A1:B12, 2, 0)), "×"),
"select count(Col2) where Col2 is not null
group by Col2 pivot Col1"), "offset 1", ),
SEQUENCE(COUNTUNIQUE(D1:D9), 1, 1, 0)))})
formula explanation
I am currently using char (10) to merge columns, from a separate tab called "scripts", into one cell based on a name.
=IFERROR(TEXTJOIN(CHAR(10),1,QUERY(Scripts!$A$3:A,"select B, C, D, E where A ='"&A1&"'")))
my information shows up in a list. is there a way to combine columns B+C and then D+E.
row 1 is what my data looks like on "scripts" tab.
row 7 is what the data looks like with the above equation.
row 12 is what i would like the equation to do.
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A1:A, QUERY(
{Scripts!A:A, Scripts!B:B&" "&Scripts!C:C&CHAR(10)&Scripts!D:D&" "&Scripts!E:E},
"where Col1 is not null"), 2, 0)))
update:
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(QUERY(
{Data!A2:A&"×", CHAR(10)&TEXT(Data!B2:B, "m/d/yy")&
CHAR(10)&Data!C2:C&", "&Data!D2:D&", "&Data!E2:E, ROW(Data!A2:A)},
"select max(Col2) where not Col1 starts with '×' group by Col3 pivot Col1")
,,9^9)), "×")), "^"&CHAR(10), ))
Currently, I have this
=QUERY(
QUERY(
'Raw Paste'!C2:E, "select C, count(C) where C is not null group by C order by C label count(C) ''"
), "WHERE Col2 >= 2")
The second QUERY() is so I can filter the aggregate function like an SQL HAVING function...
That will do this:
What I want to do though is next to the count, I want a 3rd column that joins the invoice numbers that are included in the aggregate.
This would be trivial with ARRAY_AGG(C) but google sheets ain't that fancy.
I've considered maybe using INDEX/MATCH somehow but I dunno.. I need to join the strings together where an item appears more than once.
C D
111 PPP
222 OOO
222 QQQ
The output I want:
C D
222 OOO, QQQ
It can be done by using FILTER and JOIN
=IFERROR(JOIN(", ", FILTER(D2:D, C2:C = A3)))
FILTER will look in C2:C for A2 and return the values from D2:D, which get passed to JOIN
=ARRAYFORMULA(REGEXREPLACE(TRIM({QUERY(QUERY(C:D,
"select C,count(C) where C is not null group by C pivot D", 0), "select Col1 offset 1", 0),
TRANSPOSE(QUERY(TRANSPOSE(IF(ISNUMBER(QUERY(QUERY(C:D,
"select count(C) where C is not null group by C pivot D", 0), "offset 1", 0)),
QUERY(QUERY(C:D,
"select count(C) where C is not null group by C pivot D", 0), "limit 0", 1)&",", ))
,,999^99))}), ",$", ))
I have a data set with multiple columns and roughly 1000 rows. I need to find out how many times certain combinations of columns can be found within the data set.
In my example below, columns A:B represents the raw data set. In C2 I have a formula that finds all non-unique combinations from columns A:B. What I need is a formula that counts how many times combinations in columns C:D are found within columns A:B. The desired output should be in ColE.
you can do it all in one go... delete columns C, D, E and use this formula:
=ARRAYFORMULA(QUERY({A2:B, A2:A&B2:B},
"select Col1,Col2,count(Col3)
where Col1 is not null
group by Col1,Col2
order by count(Col3) desc
label count(Col3)''"))
for a selected combination only use this formula in E2 cell:
=ARRAYFORMULA(IFERROR(VLOOKUP(C2:C&D2:D, QUERY({A2:A&B2:B},
"select Col1,count(Col1)
where Col1 is not null
group by Col1
label count(Col1)''"), 2, 0)))
It's always better to share a copy of your spreadsheet, but try entering in E1
={"Count"; ArrayFormula(IF(LEN(C2:C), VLOOKUP(C2:C&D2:D, query({A2:A&B2:B, A2:B}, "Select Col1, count(Col3) where Col1 <>'' group by Col1"), 2, 0),))}
and see if that works?
Note that you can create the same output (columns C, D and E) with a single formula
=query(ArrayFormula(query({A2:B, A2:A&B2:B}, "Select Col1, Col2, count(Col3) where Col1 <>'' group by Col1, Col2")), "where Col3 >1 label Col1 'Value 1', Col2 'Value 2'")