I'm using google sheets, and trying to look up the string value in cell A4, check column A of Sheet2 for a matching string, then (once found) return the soonest date in column C where;
Column A matches A4
Column I = TRUE
Column J = blank
The formula I've come up with is this;
=ARRAYFORMULA(MIN(IF((Sheet2!A:A=A5)(Sheet2!I:I=TRUE)(Sheet2!J:J=""),Sheet2!C:C,"")))
which returns the error
invalid call to non-function
My previous formula;
=ARRAYFORMULA(MIN(IF((Sheet2!A:A=A4)*(Sheet2!I:I=TRUE),Sheet2!C:C,"")))
Was returning a date, but I needed to add the additional IF statement to check column J is blank, and that's where I think I'm failing - but I'm not entirely sure why. I've tried
Sheet here with example, feel free to edit;
https://docs.google.com/spreadsheets/d/1kUQ2Ut59VZtKGWwyNCwAilIEWHWSk45HP0u1qMORsRA/edit?usp=sharing
Any help here would be much appreciated.
You may try:
=sortn(filter(Sheet2!C:C,Sheet2!A:A=A4,Sheet2!I:I=TRUE,Sheet2!J:J=""),1,,1,1)
You just need to put the asterisks in like you did with your original formula
=ARRAYFORMULA(MIN(IF((Sheet2!A:A=A5)*(Sheet2!I:I=TRUE) * (Sheet2!J:J=""),Sheet2!C:C,"")))
But also check the locale settings of your sheet because the dates appear to be in DD/MM/YYYY format while the locale is set to US (MM/DD/YYYY).
Or you could try using a query:
=query({Sheet2!A2:A,Sheet2!C2:C,Sheet2!I2:I,Sheet2!J2:J},"select Col1,min(Col2) where Col3=true and Col4 is null group by Col1")
Related
Link to example file:
https://docs.google.com/spreadsheets/d/1dCQSHWjndejkyyw-chJkBjfHgzEGYoRdXmPTNKu7ykg/edit?usp=sharing
The tab "Source data" contains the data to be used in the query on the tab "Query output". The tab "Desired result" shows what I would like the end result to look like.
The goal I'm trying to achieve is to have the formula in cell A2 on the tab "Query output" to populate the data in all four of the columns, so that it looks exactly like the "Desired result" tab. I know I can get the same result simply by entering additional formulas in C2 and D2, but this is not the objective, I need the results to come specifically from the single formula in A2.
The information in the "Additional data 1" column should simply repeat the word "Test" for every row that contains data in the first two columns. The information in the "Additional data 2" column should simply repeat the data from cell 'Source data'!A1 for every row that contains data in the first two columns.
Please feel free to edit the example file as it only contains dummy data. If you like, you can copy the tab "Query output" to create your own working formula for illustrative purposes.
EDIT:
I'm thinking along the lines of creating an array that consists of the required data for the columns "Additional data 1" and "Additional data 2" and then combining that array with the array of the query result which provides the first two columns. I've been experimenting with this in various ways, but so far the only result I have achieved is an error on the first cell of the query results. I also have no idea yet how I could make sure that the second array contains an equal amount of rows to the query result.
You can add static data into query:
=QUERY('Source data'!A3:B,"SELECT A,B, 'Test', '" & 'Source data'!A1 &"' WHERE A IS NOT NULL LABEL A '', B '', 'Test' '', '" & 'Source data'!A1 &"' ''")
Many thanks to #basic for the provided assistance! The insights were a great help to solving my issue. That said, I have muddled along a bit, and I've come up with a slightly different solution which I find better suited as it gives true blank values instead of a column filled with spaces.
First of all, instead of querying directly on the source data, I built an array and queried on that. I used the two existing columns (A and B) from the source data and added a third column to the array which does not exist in the source data. In order to make sure that the third column would consist of blank values, I used the IFERROR formula.
=IFERROR(0/0)
The formula above returns a blank because dividing by zero forces an error and the IFERROR method returns a blank unless an alternative return value is specified.
In order to be able to use this formula in an array however, it had to be tweaked slightly, because as it is it would only return a single blank cell value instead of a column of blank values. To do this, I used an already existing column from the source data, and then encapsulated it in an ARRAYFORMULA.
=ARRAYFORMULA(IFERROR('Source data'!A3:A/0))
Using this, the resulting array has the following formula.
=ARRAYFORMULA({'Source data'!A3:A,'Source data'!B3:B,IFERROR('Source data'!A3:A/0)})
This creates an array consisting of the two original columns A and B from the source data, plus an additional third column filled with blank values. This array can now be queried upon, and using the tricks previously provided by #basic the desired result as specified in the original question can be achieved.
Due to the query now being used upon a user-defined array, the columns in the SELECT statement now have to be referred to as Col1, Col2, Col3, instead of A, B, C. The final formula now looks like this.
=QUERY(ARRAYFORMULA({'Source data'!A3:A,'Source data'!B3:B,IFERROR('Source data'!A3:A/0)}),"SELECT Col1,Col2,'Test',Col3,'"&'Source data'!A1&"' WHERE Col1 IS NOT NULL LABEL 'Test' '','"&'Source data'!A1&"' ''")
I hope this information may prove of use to someone else as well.
My spreadsheet is collecting data from a form
On another tab I'm showing the responses that match "Lesson day" with "Today's date" (in the example, all the lessons are showed).
As you can see, the "e-mail" field is filled out only once.
Is there a way to automatically fill the "e-mail" field in the second tab? Maybe matching the "Student Code" with the "e-mail" fields in the first tab?
I've tried the MATCH() function but it returns only the position. I feel like I need to combine MATCH() with other functions but I have no idea about where to start
EDIT: Having the email adresses on another column would work too.
SOmething like: if the "Student Code" in the 2 tabs matches, show the email adress for that "Student code"
try:
=ARRAYFORMULA(IFNA(VLOOKUP(D4:D, FILTER({form!E2:E, form!G2:G}, form!G2:G<>""), 2, 0)))
change form to match the sheet name of your form sheet
As suggested, I created an auxiliary table (just called Sheet7) and getting closer to the desired result
In A column I used
=UNIQUE(Lessons!E:E)
In column B I used
=INDEX(Lessons!A:M, MATCH(A2,Lessons!E:E,0),7)
Then, on my second spreadsheet, I could get all the e-mail adress using the following formula
=INDEX(Sheet7!A:B, MATCH(D4,Sheet7!A:A,0),2)
I've tried to use ArrayFormula on the auxiliary table
ARRAYFORMULA(if(A2:A="",,INDEX(Lessons!A:M, MATCH(A2:A,Lessons!E:E,0),7)))
But it doesn't work. It shows only the email adress matched from the cell A2, ignoring A3, A4,...
A different approach:
Make an extra column in your form responses sheet called "Student E-mail".(In this example it is column "I")
In row 2 of that column, write the following formula:
=ARRAYFORMULA(IF(ISBLANK(G2:G),VLOOKUP(F2:F,INDIRECT("F$2:G"&ROW(I2:I),TRUE),2),G2:G))
Use that column for the emails in your other tab (hide the original email column)
Update:
Using array formula, you don't have to manually drag & drop. And it keeps going as new rows are added.
Usually MATCH is combined with INDEX
You should build an auxiliary table with one column for names and another for ee-mails.
To build the auxiliary table from the collected data you could use something like this
=UNIQUE(FILTER({Lessons!E:E,Lessons!G:G},LEN(Lessons!G:G)))
The above is better than using a formula for each column as this prevent having mismatching data.
INDEX / MATCH usually doesn't return the "expected" results in an ARRAYFORMULA. Instead use VLOOKUP.
NOTES:
Please bear in mind that every time that you edit a value the formula will be recalculated. If you have a lot of formulas (like when doing a fill down to copy a formula to all the cells in a column) or having an ARRAYFORMULA with open ended references i.e. G2:G this could affect your spreadsheet performance.
If you go for using an ARRAYFORMULA, use ARRAY_CONSTRAIN to limit the number of rows returned by your formula.
Related
How to map values between columns in worksheets
I am working with this spreadsheet of airport data.Sorry can't figure out how to format the headers, but first column is Origin IATA, 2nd is Dest IATA, and 3rd if Concatenate Route
Origin IATA, Dest IATA, Concatenate Route
LHR JFK LHR-JFK
JFK LHR JFK-LHR
CAN PEK CAN-PEK
PEK CAN PEK-CAN
JFK LAX JFK-LAX
LHR DXB LHR-DXB
DXB LHR DXB-LHR
Picture version:
Right now, I just have =CONCATENATE(C:C,"-",D:D) as the formula, but I actually need them to concatenate in alphabetical order so I can collapse CAN-PEK as one round trip route.
I found someone with a similar question here: Excel formula to take values from cell range, sort alphabetically and write as a single string
And I tried to modify the code of the accepted answer, but I keep getting errors because I don't know what I'm doing. I also tried VBA code, doing it in access, and many other Stackoverflow solutions, but I am stuck.
Does anyone know how I need to write the code to get it to do what I want?
Thank you!
With Excel one can use mathematical inequalities for text strings in many cases. In C2 put:
=IF(A2<B2,A2&"-"&B2,B2&"-"&A2)
Then copy down
When using a formula, you would need to use your existing formula as a helper column and then add the final column containing the sorted results. The example below has the named range "concat" assigned to the concatenate column and the named range "order" assigned to the sort order column.
Note, if your data is in an Excel structured table, you don't need to use defined names. You can select table column and Excel will insert the proper syntax.
Sort Order Column (column E, copy down)
=COUNTIF(concat,"<="&E2)
Alpha Sorted Column (column F, copy down)
=INDEX(concat,MATCH(ROWS($E$2:E2),order,0))
I have a list of item numbers.Some of them don't have details associated with them. I would like the list of item numbers that don't have info associated. they can be identified with #N/A error.
I'm running excel 2007.
i am using this array formula to return the associated details. which are in column A
=IF(ISERROR(VLOOKUP(J12,A:H,{2,3,4,5,6,7,8},FALSE)),"",VLOOKUP(J12,A:H,{2,3,4,5,6,7,8},FALSE))
if the lookup can't find the associated item number in column a it returns blanks, otherwise it returns the associated data.
the ones that error, i need a list of those.
is there a formula or a vba macro to get this information?
thanks for your time
Ian
As XORLX said: why you are using {values} as its picking items from column B?
Anyway you can change your formula with
=IFERROR(VLOOKUP(J12,A:H,{2,3,4,5,6,7,8},FALSE),"N/A")
So in case of error it will give N/A which you can later filter.
But I think you want result as in this pic
Sample File
Where
K6=IFERROR(INDEX(A:H,MATCH(J6,A:A,0),(IF(INDIRECT("B"&MATCH(J6,A:A,0))<>"",2,IF(INDIRECT("C"&MATCH(J6,A:A,0))<>"",3,IF(INDIRECT("D"&MATCH(J6,A:A,0))<>"",4,IF(INDIRECT("E"&MATCH(J6,A:A,0))<>"",5,IF(INDIRECT("F"&MATCH(J6,A:A,0))<>"",6,IF(INDIRECT("G"&MATCH(J6,A:A,0))<>"",7,IF(INDIRECT("H"&MATCH(J6,A:A,0))<>"",8))))))))),"N/A")
In my example I am looking for Joy which is in Row 2.
Now after finding Row 2 it will go and check 2nd Column B which is empty so it will go for 3rd C and so on and when will return the data from the 1st column and if find nothing then will return error.
I am facing a problem. i have a huge data file in text format and the entries are in this format:
18 1 1471-213X-6-54-12 503 5.333333e-001 xyz
the First column range from 1-22 and first column and third column must not be duplicated. If duplicated values exists i want to remove them. I am working in Matlab.
I could not find any suitable stuff to solve this problem.
Anybody hint/help will highly be appreciated.
Thanks in advance.
Mehdi
Here is a hint, suppose your first column is called f, and your third colum is called t.
you may be interested in the following commands:
[xxx,IA_f] = unique(f)
[xxx,IA_t] = unique(t)
[xxx,IA_tf] = unique([f t], 'rows')
Assuming that your data is in matrix'M' and you have selected IA as the proper index, you can do:
M_unique = M(IA,:)