How to cross join 2 lists? [duplicate] - google-sheets

This question already has answers here:
Generate all possible combinations for Columns(cross join or Cartesian product)
(5 answers)
How to perform Cartesian Join with Google Scripts & Google Sheets?
(4 answers)
Google sheets - cross join / cartesian join from two separate columns
(3 answers)
Closed 1 year ago.
I have two lists in Google Sheets. Looking to concatenate the results of both into one list, but quickly as both lists change semi-frequently.
I have a list of stores that rarely changes, and a list of products sold that changes monthly. Looking to combine them into unique values so I can look up off of them.
For example, I have list A with 2 items in it, and list B with 4 items in it. Looking to output:
A1_B1
A1_B2
A1_B3
A1_B4
A2_B1
A2_B2
A2_B3
A2_B4

For instance
=flatten(arrayformula(A1:A4&"_"&transpose(B1:B3)))
you can also try
=flatten(arrayformula(offset(A1,,,COUNTA(A:A))&"_"&transpose(offset(B1,,,COUNTA(B:B)))))
this formula will be adjust to the number of items

Related

Shuffle a deck of 7 hypothetical trading cards and list out the orders they can come in a Google Sheet [duplicate]

This question already has answers here:
How to list all permutations without repetition?
(2 answers)
Closed 5 months ago.
Say I have a set of seven unique trading cards and I want to shuffle them and list them out for all their possible permutations (pool of 7, taking 7). No card may be duplicated within each permutation of an arrangement as I have only one of each card, and I am not looking for the number of permutations available. I want the list itself.
How would I use one Google Sheets formula (no manual data entry on an iterative basis past the first line) to shuffle these cards: A, B, C, D, E, F, and G into a list of unique permutations per row? They can be arranged into a tidy list (ABCDEFG) within each cell or each card to a column, but along each permutation, there must only be one of each card (ABACDEF shouldn't exist).
I've looked everywhere to shuffle just one column of values into all possible ordered sets with no repeated objects per set. Still, I lack the remembered terminology to search for the right answer.
If you know about the solution, give me the link please.
https://webapps.stackexchange.com/questions/129778/is-there-a-formula-to-list-all-possible-2-card-combinations-of-4-playing-cards-i
Reducing the question to trading cards for this post inspired me to pose it that same way to Google, and I found this. I believe the above example may be scaled up to 7 in 7 cards.
Feel free to try coming up with a better answer... I noticed the formula in the above post is rather long. I'm looking for the most compact answer available.
EDIT: Aha! I think I found one better.
Generate all possible combinations for Columns(cross join or Cartesian product)
I was having issues running into the rept function's 32000 character limit. So, I added the lengthy transposition formula found here:
https://stackoverflow.com/a/73523983/4143583
Combining that formula within a query similar to the first link's answer but scaled up a bunch ("where Col1 <> Col2 and Col2 <> Col3", etc.) seems to have solved my issue with repeated members within each permutation.

How to Query a column where numbers are mixed with text (GOOGLE SHEET) [duplicate]

This question already has answers here:
Query is ignoring string (non numeric) value
(2 answers)
Closed 5 months ago.
I'm using a query to pull data from a multi-sheets in Google Spreadsheet that is populated by a Google Form. If the form has only numbers, there is no problem. However, if there's a mixed of text and number then it did not work.
=QUERY({Sheet1!A:S;Sheet2!A:S},"SELECT* WHERE Col4<>''",0)
EDIT: Added the second one here:
=QUERY(Sheet2!A:S,"SELECT A,C,D,E,F,G,H,I,J,K,L,R WHERE G IS NOT NULL ORDER BY G LABEL R 'FRUIT'",TRUE)
Regards,
Yes, this is how QUERY works. It only pulls the most frequent data type per column. To pull mixed data types, you can use FILTER:
=FILTER({Sheet1!A:S;Sheet2!A:S},{Sheet1!D:D;Sheet2!D:D}<>"")

Combine multi-row source data across separate tabs into one summary tab without using hard references to individual sheet names [duplicate]

This question already has answers here:
How to create INDIRECT array string of multiple sheet references in Google Sheets?
(2 answers)
Closed 2 years ago.
I would like to create a summary sheet that reports the same data from across multiple tabs and doesn't rely on referencing individual sheet names in the formula/code. I have successfully done this when there is only one line of data representing each tab (using getSheetnames or Index scripts).
But, the data I want to summarize has multiple rows from each tab that need to be reported on a summary sheet.
I've successfully managed to combine and report the data from separate sheets into the Summary using a query/array combo where the query range includes each sheet and separated with ";". This can be done using cell references to the Sheetname list as well.
However, this needs to be more dynamic as sheets will be added/removed regularly and I would like to not have to re-write the query every time to add/remove individual sheet names.
SUMIF also works, but with similar limitations.
I believe my main challenge is using a list of sheet names which I can generate (listing one sheet per row) and associating those names formula/code that will produce summary results in multiple rows.
If Sheet names are in Column A, the following formula displays data combined from multiple tabs
=ArrayFormula(query({INDIRECT(A3&"!A2:A200"),to_text(INDIRECT(A3&"!B2:B200")),INDIRECT(A3&"!C2:C200");INDIRECT(A4&"!A2:A200"),to_text(INDIRECT(A4&"!B2:B200")),INDIRECT(A4&"!C2:C200")},"select Col1,Col2,Col3 where Col1 contains 'Project'"))
BUT, I want to reference my Sheetnames list without having to write in actual sheetnames or cell references to the formula.
Here's a link to a dummy workbook with sample.
I realize I'm late to the party on this question, but have you considered a Google Form with 5 questions:
Project?
Phase?
Transaction?
Start?
End?
That way, all your data would be in a single tab. People could input using the form, and you could still have project by project outputs for viewing/analysis using a simple query.
Google Sheets was designed from the ground up to be different from excel in specifically this way. There are all sorts of incentives to condense your data SOURCES while making it easy to disaggregate your ANALYSIS. While Excel is exactly the opposite. It's easy to keep track of things on tons of different tabs, and aggregate it all in one place. Yet there is no such thing as FILTER() or QUERY() to do the opposite.

UNPIVOT function in Google Sheets [duplicate]

This question already has answers here:
How do you create a "reverse pivot" in Google Sheets?
(10 answers)
Closed 5 months ago.
Background: Have a sheet that is being constantly updated with new rows, where the rows are in a PIVOTED fashion. Think left column is date, following columns are staff-ids - extending to right as new staff joins.
I have researched a bit - but did not find my required solution. Eg: the QUERY function has PIVOT but NO UNPIVOT function. So ...
Is there a FORMULA based method (without scripting) that can produce the normalized/UNPIVOTed data from the already pivoted data?
I'm not looking for a solution, hence no sample sheet. But rather, if this is possible, please point me to the functions that could do it ?
I don't know a formula that does this directly. What I would do is:
1) Use COUNT() twice, to count the columns and rows that contain data. Let's call these C and R.
2) Use simple formulas to write all combinations of C and R into C*R rows and 2 columns. Use more rows to allow for C and R to grow.
3) Use OFFSET() to read the pivoted data into the 3rd (unpivoted) column.
4) If you need to get rid of empty cells, use QUERY() on the 3 unpivoted columns.
Hope that helps.

Google Sheets copy between columns based on match? [duplicate]

This question already has answers here:
How to do Vlookup using two search columns to compare with two result columns?
(2 answers)
Closed 1 year ago.
See my following spreadsheet: https://docs.google.com/spreadsheets/d/1SO3Z-liX1T61W47gKv5ugWFiQKsHa0-XBQsi1A7dTE0/edit?usp=sharing
I'm trying to create a formula that I can put into column C (the missing emails) based off of the names and emails in columns E-G.
In other words, I'm only missing the emails for folks to the left. The columns on the right has the data I need. I just need a formula that will auto-fill the missing emails based on matching the names in columns A/B and E/F.
I hope that makes sense. This is just an example spreadsheet. The real sheet I need to work with has hundreds of missing emails.
=ARRAYFORMULA(VLOOKUP(A2:A8&B2:B8,{E2:E14&F2:F14,G2:G14},2,0))

Resources