I'm using Google Sheets to create a product list which combines two sets of data. I'm wondering if there is a function which will effectively create a list which is a product of the two individual lists.
I can achieve this in a number of ways such as creating an array and then using an offset calculation which I copy down the output column but I'm hoping to find a solution which will take the two lists as arrays and output all of the combinations.
I'm wanting to do it this way because the list lengths are dynamic.
I've looked at ={list_1;list_2} but this just placed the second list under the first list, but it does it as a single cell function.
I've created a spreadsheet which illustrates what I'm trying to achieve and what I've managed to achieve so far...
https://docs.google.com/spreadsheets/d/1Q3lexm06utmI1IE2HmjtNjBKHZc771KVNp1dDjL3jxs/edit?usp=sharing
If your lists are in A and B columns, put this in the C column and copy down until the length of the product of the two list lengths.
=CONCAT(INDEX(A:A,INT((ROW()-1)/COUNT(B:B))+1),INDEX(B:B,MOD(ROW()-1,COUNT(B:B))+1))
I suppose you could throw in some logic that hides the output if you go too far and then just fill the whole column.
This is adapted from here.
I found the answer elsewhere on stackoverflow.com.
The answer is:
=ArrayFormula(transpose(split(rept(concatenate(A2:A&char(9)),counta(B2:B)),char(9)))&" "&transpose(split(concatenate(rept(B2:B&char(9),counta(A2:A))),char(9))) )
and I found it here
Generate all possible combinations for Columns in Google SpreadSheets
wrap it into SUBSTITUTE to get rid of that space:
=ARRAYFORMULA(SUBSTITUTE(
TRANSPOSE(SPLIT(REPT(CONCATENATE(A3:A&CHAR(9)),COUNTA(B3:B)),CHAR(9)))&" "&
TRANSPOSE(SPLIT(CONCATENATE(REPT(B3:B&CHAR(9),COUNTA(A3:A))),CHAR(9)))," ",""))
and to sort it use:
=ARRAYFORMULA(SORT(SUBSTITUTE(
TRANSPOSE(SPLIT(REPT(CONCATENATE(A3:A&CHAR(9)),COUNTA(B3:B)),CHAR(9)))&" "&
TRANSPOSE(SPLIT(CONCATENATE(REPT(B3:B&CHAR(9),COUNTA(A3:A))),CHAR(9)))," ",""),1,1))
Related
I'm trying to take the names from column A compare them to the names in column B and then have the similar names get listed in column C.
The problem is these names are automatically updated and out of order, and I need the function in column C to update with them. Also, the names will not be in order, this is why I can't use A=B function. The picture shown is an example of what the solution would look like or something similar. After completing this, I would like to continue using the same function to break down the name data even more. Watched a lot of videos on this, can't find anything specific enough to work.
Side note, I have found a way to do this using different pages within the sheets but not in the same sheet side by side. ex. of what solution
I have tried watching lots of YouTube videos, but nothing goes into detail enough and seem to only explain when similar values are next to each other in column A and B.
This is what I use for 2 different sheets but can't find / understand why when changing values in function to single sheet it wont work:
=filter(Sheet1!A2:B,ISNUMBER(match(Sheet1!A2:A,Raid1!A2:A,0)))
Also, another side note: Can't use True or False. And for uneven number of names in the list ex. Column A has 10 and B has 7 it sorts A for names in B and post similar in C.
Try below formula-
=FILTER(C3:C,INDEX(COUNTIFS(D3:D,C3:C))>0)
You can use VLOOKUP to check common values between columns and store them in another column.
=IFERROR(VLOOKUP(A:A,B:B,1,false),"")
Although this will create gaps in the output column. you can get rid of it by by simply using a filter or so.
all you need is:
=FILTER(C3:C; COUNTIFS(D3:D; C3:C))
I'm able to embed an adjacent range using the query parameter, but if I can't get it to work with non-adjacent ranges. Here are some of my attempts using a public link:
# This works. It shows column A
https://docs.google.com/spreadsheets/d/e/2PACX-1vS-vH8TLPDj64Xqm2DQaS4MKT13y9yu6Nz69cwEw-sd-VapPyG_iW4_nrs2XxpMEdN41hbrfb_SwA2c/pubhtml?gid=0&single=true&range=A:A
# None of these work. I'd like to see columns A and C
https://docs.google.com/spreadsheets/d/e/2PACX-1vS-vH8TLPDj64Xqm2DQaS4MKT13y9yu6Nz69cwEw-sd-VapPyG_iW4_nrs2XxpMEdN41hbrfb_SwA2c/pubhtml?gid=0&single=true&range=A:A,C:C
https://docs.google.com/spreadsheets/d/e/2PACX-1vS-vH8TLPDj64Xqm2DQaS4MKT13y9yu6Nz69cwEw-sd-VapPyG_iW4_nrs2XxpMEdN41hbrfb_SwA2c/pubhtml?gid=0&single=true&range={A:A,C:C}
https://docs.google.com/spreadsheets/d/e/2PACX-1vS-vH8TLPDj64Xqm2DQaS4MKT13y9yu6Nz69cwEw-sd-VapPyG_iW4_nrs2XxpMEdN41hbrfb_SwA2c/pubhtml?gid=0&single=true&range=query({A:A,C:C})
https://docs.google.com/spreadsheets/d/e/2PACX-1vS-vH8TLPDj64Xqm2DQaS4MKT13y9yu6Nz69cwEw-sd-VapPyG_iW4_nrs2XxpMEdN41hbrfb_SwA2c/pubhtml?gid=0&single=true&range=query(A:A,C:C)
Is it possible to do this?
I do not think this is possible because if two non adjacent ranges were to be published together, Google Sheets would not know how to combine them:
Shall they become adjacent skipping the ranges inbetween?
Shall the distance between them be preserved?
Your best bet would be copy the ranges of interest into a new sheet and either arrange them together or leaving empty spaces inbetween - depending on your intention - and then publish the new, preformatted sheet instead of the original one.
Problem
I have a column with duplicate items in Google Sheets, and I would like to get one of the unique values (say, the last one) in the cell of the formula. Is there a way to do this with just formulas (i.e., no scripts/macros)?
What I've tried
Not sure if this is the best way, but I've tried using the UNIQUE(range) function, which returns a list of distinct values, and I tried to pick one with FILTER(range, condition1, [condition2, …]), but I've only managed to do it when I know in advance and hard-code in the number of unique values.
Since I can get the length of the unique list with =LEN(UNIQUE(my_range)), I tried using the REPT(text_to_repeat, number_of_repetitions) function.
For example,
=REPT(0&";",2) & 1 returns "0;0;1"
but
=FILTER(UNIQUE(A$1:A$26), {REPT(0&";",2) & 1})
(or any variation I tried) doesn't quite work.
P.S.
I realise this is not the most suitable problem for a spreadsheet, and I do wish I was using something like Python, but this is the restriction at the moment.
try:
=QUERY(UNIQUE(A1:A), "offset "&COUNTA(UNIQUE(A1:A))-1)
Or more old-school using index:
=index(unique(A:A),counta(unique(A:A)))
You can also just enter a number fot the one you want e.g.
=index(unique(A:A),2)
I'm trying to do a couple of different things with a spreadsheet in Google and running into some problems with the formulas I am using. I'm hoping someone might be able to direct me to a better solution or be able to correct the current issue I'm having.
First off all, here is a view of the data on Sheet 1 that I am pulling from:
Example Spreadsheet
The first task I'm trying to accomplish is to create a sheet that lists all of these shift days with the date in one column and the subject ("P: Ben" or S: Nicole") in another column. This sheet would be used to import the data via a CSV into our calendar system each month. I tried doing an Index-Match where it used the date to pull the associated values however I found that I had to keep adjusting the formula offsets in order to capture new information. It doesn't seem like Index-Match works when multiple rows/columns are involved. Is there a better way to pull this information?
The second task I am trying to accomplish is to create a new tab which lists all the dates a specific person is assigned too (that way this tab will update in real time and everyone can just look at their own sheet to see what days they are on-call). However, I run into the same problem here because for each new row I have to change the formula to reflect the correct information otherwise it doesn't pull the correct cell when it finds a match.
I would appreciate any and all information/advice on how to accomplish these tasks with the formula combination I mentioned or suggestions on other formulas to use that I have not been able to find.
Thanks in advance!
Brandon. There are a few ways to attack your tasks, but looking at the structure of your data, I would use curly brackets {} to create arrays. Here is an excerpt of how Google explains arrays in Sheets:
You can also create your own arrays in a formula in your spreadsheet
by using brackets { }. The brackets allow you to group together
values, while you use the following punctuation to determine which
order the values are displayed in:
Commas: Separate columns to help you write a row of data in an array.
For example, ={1, 2} would place the number 1 in the first cell and
the number 2 in the cell to the right in a new column.
Semicolons: Separate rows to help you write a column of data in an array. For
example, ={1; 2} would place the number 1 in the first cell and the
number 2 in the cell below in a new row.
Note: For countries that use
commas as decimal separators (for example €1,00), commas would be
replaced by backslashes () when creating arrays.
You can join multiple ranges into one continuous range using this same
punctuation. For example, to combine values from A1-A10 with the
values from D1-D10, you can use the following formula to create a
range in a continuous column: ={A1:A10; D1:D10}
Knowing that, here's a sample sheet of your data.
First Task:
create a sheet that lists all of these shift days with the date in one
column and the subject ("P: Ben" or S: Nicole") in another column.
To organize dates and subjects into discrete arrays, we'll collect them using curly brackets...
Dates: {A3:G3,A7:G7,A11:G11,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
This actually produces two rows rather than columns, but we'll deal with that in a minute. You'll note that, because there are two subjects per every one date, we need to effectively double each date captured.
Dates: {A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
Still with me? If so, all that's left is to (a) turn these two rows into two columns using the TRANSPOSE function, (b) combine our two columns using another pair of curly brackets and a semicolon and (c) add a SORT function to list the dates in chronological order...
=SORT(TRANSPOSE({{A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15};{A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}}),1,TRUE)
Second Task:
create a new tab which lists all the dates a specific person is
assigned too (that way this tab will update in real time and everyone
can just look at their own sheet to see what days they are on-call).
Assuming the two-column array we just created lives in A2:B53 on a new sheet called "Shifts," then we can use the FILTER function and SEARCH based on each name. The formula at the top of Ben's sheet would look like this:
=FILTER(Shifts!A2:B53,SEARCH("Ben",Shifts!B2:B53))
Hopefully this helps, but please let me know if I've misinterpreted anything. Cheers.
Is it possible to nest simple programs within a Google Sheets, similar to how you would with Visual Basic for Applications in Excel? Or alternatively a simple = syntax using regex, if there is a way to do that in Google Sheets?
I want to take a list of multiple names (name1, name2, name3) in a single cell from across multiple identical sheets and transpose them to another sheet within the same spreadsheet, check for duplicates and ignore capitals, etc. Is there a way to do this?
You are asking for an easy answer to a composite problem. To solve this, I would split the job into separate chunks:
Split the input cell content into
different cells. As it is unclear
how this format is, I cannot advice
on any specific method. Check out
ImportRange function or similar.
Transpose them. use =TRANSPOSE(area)
Remova duplicates, use =UNIQUE(area)
Check the Google Spreadsheet function list for details.
Nest them: =UNIQUE(TRANSPOSE(A1:C15)).
LOWER cannot be used in this nest as it works with only text input, not array input. Although you can use it for the first input cell.