I need to join two pairs of column into two columns (not just one) and eliminate duplicates.
Take a look a this capture to see what I mean. I need to join yellow and blue cells to get the result in the green cells.
I tried with UNIQUE but it only accepts one argument, then I don't see how to add the second pair of columns.
The closest I get is this =CONCATENATE(UNIQUE(A3:B7);UNIQUE(D3:E5)) but I get all values in just one cell. Not what I need.
You can also take a look a this spreadsheet: https://docs.google.com/spreadsheets/d/1-x5KINErYKgwxgv5ZCpxbGdxRdp6NBDWMK2Cxhl5Xy8/edit?usp=sharing
You can use the following formula:
=UNIQUE({A3:B7;D3:E6})
Using curly quotes {} we create an array. Using ; we place these values one under the other and we then use unique.
Related
How can I take multiple rows of different data for one user, and move them into columns so that each user has only one row.
In my example, I have three tables. The table in red is the current data I have. The tables in green are what I want to convert the data to.
I tried moving each value into its own column with a formula placing a formula in a different column and moving the data over like this: In C2, =IF B2=21, B2' then copying the data into one row and deleting the others. This is long and complicated process and I am wondering if there is a better way.
https://docs.google.com/spreadsheets/d/1utqqw1Am0C_x80t1BiswHmIdWzEhNDHq4vtdBOnkGMI/edit?usp=sharing
You may try:
1st table
=byrow(unique(tocol(A2:A,1)),lambda(z,{z,join(", ",filter(B:B,A:A=z))}))
2nd table
=byrow(unique(tocol(A2:A,1)),lambda(z,{z,torow(filter(B:B,A:A=z))}))
I have multiple tables populated in the same sheet, but need them in a single table. How do I dynamically create a single table? The raw data will change, so it needs to accept additional rows as they populate.
Here is a demo document with the raw data and desired effect.
https://docs.google.com/spreadsheets/d/1V8ytyN-qSUW0Wrba7FxmQ242YXSNQ18y6nneEz6bS5g/edit?usp=sharing
Your raw data should remain alone in its sheet. So first, remove everything you currently have in Sheet1!A12:D, since it will interfere with your ability to write formulas that allow the raw data in A:D to expand downward.
Once you've removed that, add a new sheet. In that sheet, use this formula:
=QUERY({Sheet1!A3:D3;Sheet1!A4:D;Sheet1!F4:I},"Select * Where Col1 Is Not Null")
The curly brackets allow the formation of a virtual array. Within those curly brackets, a semicolon means "place what comes next below" while a comma would mean "place what comes next beside." Understand that such virtual arrays must keep parallel structure at all times; for instance, you can't place a range that's four columns wide over one that's only three columns wide.
As written, those stacked ranges go all the way to the bottom of the sheet, since there is no row number on the second part of the range (e.g., A4:D means "the range that starts with A4 in the upper left and runs to the bottom of Column D, wherever that is"). By doing this, you are always able to include more data without adjusting the formula.
All that is left to do is weed out blank rows. The outer QUERY as written allows us to trim that virtual array to to only those rows where the first column is not empty.
i have a sheet along with this question,the formula used in column E2 is : if(and(d2>=0,d2<=2),5. So when the column is blank it gives the value 5 My query is can we left the "E" column blank when there is no value in "D". ??? 5 must displayed only if there score between 0 & 2.
https://docs.google.com/spreadsheets/d/1XpdXcWDReB8TGvZ6ocALAilVPLDKzZXvd90YhNos0Io/edit?usp=sharing
Iker. I've added a sheet with two approaches.
If you want to drag the formula, just set an initial IF that rules out blanks like this:
=if(D2="","",if(and(D2>=0,D2<=2),5,if(and(D2>=3,D2<=4),0)))
I placed this into my sheet, E2, and dragged down as you were doing.
However, this is a great example of where array formulas are handy. An array formula can "run" your whole column from just one cell. I placed the following array formula into cell I1 of my sheet:
=ArrayFormula({"POINT";IF(H2:H="","",IF((H2:H>=0)*(H2:H<=2),5,IF((H2:H>=3)*(H2:H<=4),0,"")))})
First, keep in mind that array formulas must have unused space below them in order to fill in results. If you type anything manually below an array formula, inside the range it is trying to work on, you'll get an error. If you do want to put other data below an array formula, just limit the range in the array formula (e.g., change every H2:H to H2:H6 or whatever the end of that data range might be).
ArrayFormula() tells Google Sheets to apply this formula to the entire range in the formula. Since the range in the formula is H2:H, every cell in I2:I will be "reserved" by this array formula.
The curly brackets {} allow us to build another custom array inside the first array.
Since I want a header in I1, I put that header name first in the curly brackets. The semicolon tells the array to put the next part underneath.
The next part may look strange, but it's basically the same as your original formula, except that AND(), OR(), etc., don't work inside arrays. So the logical operators inside arrays are different. In this case, an asterisk * means AND.
The same conditions from your original formula are used here. And if it meets none of those criteria (for instance, if someone entered -1 or 7 or M somewhere in Column H, the last part of the last IF would just assign a blank.
You can use an added IF to your formula
=IF(D2="","", if(and(D2>=0,D2<=2),5,if(and(D2>=3,D2<=4),0)))
Is there a way to delete empty cells in a given range and shift the column up to the desired display as shown below? Closest I came was
=ARRAYFORMULA({A1:C1; TRANSPOSE(SPLIT(TRANSPOSE(QUERY(A2:C,,999^99)), " "))})
which removes empty cells, but splits the first names and surnames into separate cells, which I have not figured out how to avoid. Pfa a made-up sample of current and desired displays:
Current Display
Desired Display
I'm new at this, but I came up with a bit of a brute force method, which may help you.
={
{(A1:C1)};
{FILTER(A2:A100,A2:A100<>"");indirect("N1:N" & 100-counta(A2:A100))},
{FILTER(B2:B100,B2:B100<>"");indirect("N1:N" & 100-counta(B2:B100))},
{FILTER(C2:C100,C2:C100<>"");indirect("N1:N" & 100-counta(C2:C100))}}
Assuming your data block is in columns A1:C100, this formula filters blank cells from each individual column, and then pads each column with blank cells at the bottom, to make the three arrays equal in length/dimension.
Note that in "100-counta(...", the 100 is the expected maximum length of your data column.
This could be calculated, and must be the same for all three columns.
Note also that the first array is horizontal (ends with a semi-colon), followed by the three columns, stacked beside each other (ends with a comma).
Here is a working example.
https://docs.google.com/spreadsheets/d/1MGaqqGrkmIliuAzEqxPtdEVZXWPN2K5W7jFFM-ZnwgE/edit?usp=sharing
If I missed something you were trying to achieve, let me know.
Also, I'm sure that there is a more elegant way to do this, or one not requiring the use of a block of "reserved" blank cells, but I couldn't think of that at the moment.
Edit: The formula as follows also works. But you need to remember to set the "100" value to be equal to the number of rows in your data block, since we pad the columns with the necessary number of blanks rows, after removing the blank cells in each column.
={
{(A1:C1)};
{FILTER(A2:A,A2:A<>"");indirect("N1:N" & 100-counta(A2:A))},
{FILTER(B2:B,B2:B<>"");indirect("N1:N" & 100-counta(B2:B))},
{FILTER(C2:C,C2:C<>"");indirect("N1:N" & 100-counta(C2:C))}}
I have a a couple sheets that I want to filter the values of and sum them together. I have a working function:
=SUM(INDEX(Grades!M32:V32,0,B2)+INDEX(Grades!M32:V32,0,C2)+INDEX(Grades!M32:V32,0,D2)+INDEX(Grades!M32:V32,0,E2)+INDEX(Grades!M32:V32,0,F2)+INDEX(Grades!M32:V32,0,G2))
and this is working fine. The problem is it isn't really dynamic and I was wondering if there was a more efficient way to approach this instead of using so many Indexes.
Index is grabbing a horizontal range of numbers from another sheet and getting the needed index position from a small table in another sheet.
Update
I was able to get the formula working how I wanted by inserting an IF statement that would not do the VLOOKUP if one of the cells was empty.
=ArrayFormula(SUM(IF(B2:I2 <> "",VLOOKUP(1,{1,Grades!$M$32:$V$32},B2:I2+1))))
It looks a bit strange, but this is one way:
=ArrayFormula(SUM(VLOOKUP(1,{1,Grades!M32:V32},B2:G2+1,0)))
In the VLOOKUP, 1 is the value you are searching for, {1,Grades!M32:V32} is the array in which you are searching, B2:G2+1 is the column index (or rather, indices) you wish to return, and 0 dictates that you require an exact match.
{1,Grades!M32:V32} constructs a horizontal, one-row array that has 1 in the left-most element, with the values in Grades!M32:V32 to the right of it.
VLOOKUP will search down the left-most column of that array. It will always "find" the 1 that it is searching for in the left-most column, because we have purposely manufactured that.
Where the action really happens is in the third argument, where we return the columns in that manufactured array corresponding with the values in B2:G2 (I should add, I assumed that all cells in B2:G2 are populated - it will return the wrong result if any are blank). The +1 is to account for the extra element (the 1) we tacked on to the left of the lookup array.