I Need help to apply data validation by referencing from another column with a specific value.
In the given link for google sheet, I have some data where I need to restrict entry of duplicate data only if value from ColumnA is repeated and in ColumnC value is 1 but if value in ColumnC is 0 and data in ColumnA is repeated it should allow it.
https://docs.google.com/spreadsheets/d/1jIfIrB2RsCIyfk-64iyzNGz91oT82C56TDffVeFGLL0/edit?usp=sharing
Note: I have highlighted the rows which need to fixed using any solution. Solution should not allow data entry in row17 with value 1 in ColumnC as it's already available in row7 with value 1 in ColumnC.
I've created a sheet in your file 'Aresvik solution', but an anonymous user keeps altering your file so I've created another file for you here:
https://docs.google.com/spreadsheets/d/11y1cce5pNRh9KDifzZZg_VmsmWh2xrv4bBDDwM2awa8/copy
Using query, it filters out rows where Col2>1 and Col3=1:
=query({Sheet1!A:C},"where not (Col2>1 and Col3=1)",1)
Not sure what your intention is with 1230A, value 1? If you only want to ignore dupes where status = 1, then try:
=arrayformula(query({Sheet1!A:C,if(Sheet1!C:C=1,countifs(Sheet1!A:A&"-"&Sheet1!C:C,Sheet1!A:A&"-"&Sheet1!C:C),)},"select Col1,Col2,Col3 where Col4 is null or Col4=1",1))
If you want a warning when there is a duplicate status of 1, try this in cell D1:
=arrayformula({"Warning";if(if(Sheet1!C2:C=1,countifs(Sheet1!A2:A&"-"&Sheet1!C2:C,Sheet1!A2:A&"-"&Sheet1!C2:C),)>1,"Issue",)})
Related
I have a table with names on the left and corresponding work schedules to the right. I've created a separate table with some of those same names and want it to automatically fill in the corresponding work schedule for that person. Seemed simple but I'm very stuck. My level of experience with Google Sheets is what is stopping me from solving this.
Example Tables:
In the attached picture the table on the top is the original (hardcoded) data. The table on the bottom is where I want the schedule data to be automatically produced based on the name on the left. The fields with #N/A and #ERROR! are both failed formulas I tried. #N/A should have returned B7:G7. #ERROR! should have returned B4:G4.
I tried the 'LOOKUP' function with ARRAYFORMULA(INDEX) hoping to have it look up the value in the column and input the work schedule data that corresponds.
=LOOKUP("Clair",A1:A9,ARRAYFORMULA(INDEX(B1:G9)))
yielded an #N/A.
Started trying to use =If(REGEXMATCH(A13:A21,"Clair"),... ...) but the '... ...' shows where my intellectual limits are at the moment. I couldn't finish it because I think it's the wrong formula to use.
Something like this maybe?
Remove everthing in B13:G17, and put this formula in B13
=BYROW(A13:A17,LAMBDA(NAME,XLOOKUP(NAME,A1:A9,B1:G9,"NOT FOUND")))
BYROW() work with an array row by row, the given data A13:A17 has only 1 column, which is the name of staff as lookup value.
Details: https://support.google.com/docs/answer/12570930?hl=en
XLOOKUP() scan an array for a key value (lookup value), and return another array with corresponding row or col index.
Details: https://support.google.com/docs/answer/12405947?hl=en
try:
=INDEX(IFNA(VLOOKUP(A13:A17; A1:G10; SEQUENCE(1; 6; 2); )))
Example file:
https://docs.google.com/spreadsheets/d/1M-o8Mu3vBrBgs1wC1WL5kqK61m6Vu1K5ylGByKDCZTo/edit?usp=sharing
On the sheet "To be coached" I have a query in cell A2. The query might not be optimal and maybe it's convoluted, but it works, aside from one small detail that I just can't get to work. This is the current query.
=QUERY({
IFERROR(QUERY(FILTER(ARRAYFORMULA({MATCH('Quiz results'!F9:F,Team!G2:G,0),'Quiz results'!A9:A,'Quiz results'!C9:C,'Quiz results'!D9:D,IFERROR('Quiz results'!A9:A/0),"Question:"&CHAR(10)&'Quiz results'!G8&CHAR(10)&CHAR(10)&"Provided answer:"&CHAR(10)&'Quiz results'!G9:G&CHAR(10)&CHAR(10)&"Correct answer:"&CHAR(10)&'Quiz results'!G7}),'Quiz results'!G9:G<>'Quiz results'!G$7),"SELECT Col1,Col2,Col3,Col4,'Quiz',Col5,'"&'Quiz results'!B6&"','"&'Quiz results'!G6&"',Col6 WHERE Col2 IS NOT NULL LABEL 'Quiz' '','"&'Quiz results'!B6&"' '','"&'Quiz results'!G6&"' ''"),{"","","","","","","",""})
},"SELECT * WHERE Col1 IS NOT NULL ORDER BY Col2,Col1")
Column B shows names, which for the sake of the example I have obfuscated into "Person 1" and so on. The result I'm trying to achieve is that column A shows whether the person mentioned in column B has an active status or not. That information is present on the sheet "Team" in column A.
So far, I've been able to get the query to present the row number of an array based on information from the sheet "Team" which contains the status of the relevant person. To do this I used a MATCH statement.
MATCH('Quiz results'!F9:F,Team!G2:G,0)
The problem occurs when I try to get the actual "Yes" and "No" values from the "Team" sheet by combining the MATCH statement with an INDEX statement.
INDEX(Team!A2:A,MATCH('Quiz results'!F9:F,Team!G2:G,0),1)
When I do this, the entire query fails with the message "Query completed with an empty output". This is probably due to the IFERROR statement. When I remove that, the error is as follows.
Function ARRAY_ROW parameter 2 has mismatched row size. Expected: 1.
Actual: 998.
From what I can gather, this means that the INDEX+MATCH statement is providing 998 rows while the expected input for the query is only 1 row. But I don't understand why it is returning so many rows. When I use the same INDEX+MATCH statement on the sheet "Test" in cell A2, it returns only one cell as a result, giving "Yes". (That should actually give a "No" for the particular person on that row, but that is a different problem which might just be occurring due to using the statement in a different context.) Even when I encapsulate the formula in an ARRAYFORMULA, I still only get 1 cell as a result. So why is the same formula giving 998 rows when it's used in the query?
I am open to any and all ideas on how to get column A on sheet "To be coached" to show the correct "Yes" and "No" values for each person based on their status in sheet "Team" by using a single formula in cell A2. The reason for this is that in the end I want to use those values to filter the query result so that it doesn't show data for inactive people. (...WHERE Col1<>"No"...)
try removing that 1 in INDEX which will solve your ARRAY_ROW error:
=INDEX(Team!A2:A, MATCH('Quiz results'!F9:F, Team!G2:G, 0))
fyi, there is VLOOKUP:
=INDEX(IFNA(VLOOKUP('Quiz results'!F9:F, {Team!G2:G, Team!A2:A}, 2, 0)))
I'll do my best to explain this. So, I want to use Arrayformula to autofill column based on a condition.
=IFERROR(QUERY(ARRAYFORMULA(IF((Research!$B$1:$B$100)="Yes",REGEXEXTRACT(Research!$A$1:$A$100,".*"),)),"WHERE Col1 is not null")).
It does what it's supposed to, but the problem comes if that condition changes at any point (so it's not true anymore) the value in the cell filled with the array will get deleted but will also offset all the other rows after it (same happens if I insert new row with 'Yes' value in between other rows, in my Research sheet from where I extract my data from).
Is there any way if I need to make changes to the condition in the sheet from where I extract data > and not offset everything else in the sheet where I use the array formula? (either delete the entire row if the value doesn't meet the condition anymore, or insert new row if it meets the condition (not just replace the value in previous cell in its spot, cuz then all the other fields are mismatched). I'm a beginner with excel, I hope that makes sense. Sheet ex
Condition in Main Sheet > Result in Array sheet
(these are the ok examples)
Changed value to yes for Agency 3 > Inserted in Agency's 5 place > and offsets everything after it
Please refer to the spreadsheet for my examples.
Method A: Separate the sheets of input and output
Method B: Input on Research and output on Initiative
Method C: Use Google Apps Script to 'avoid' offset upon change of Take? value. (example is not provided)
I need to update a cell with a defined value automatically by comparing and referencing this data from another Google sheet.
In Sheet1 Column_C is to be updated by comparing Column_A in Sheet1 to Column_A in Sheet2.
If it is a match, and Column_B's value from Sheet2 is 1, then the result should be "issued", otherwise it should be "in-stock".
Sharing google sheet link :
https://docs.google.com/spreadsheets/d/1h_D5u16ye1CA6C7dideJVZoV8cBvZB8M3RRxXBANsf4/edit?usp=sharing
How can I accomplish this using Google Sheets?
Try this in cell C1 (delete all other values below):
=arrayformula({"Status";if(A2:A<>"",substitute(substitute(iferror(vlookup(A2:A,filter(sheet2!A:B,countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1),2,0),),1,"Issued"),0,"In-Stock"),)})
To handle items in sheet1 that are not in sheet2, you can add a value in the iferror function (the first "In-Stock" below):
=arrayformula({if(A2:A<>"",substitute(substitute(iferror(vlookup(A2:A,filter(sheet2!A:B,countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1),2,0),"In-Stock"),1,"Issued"),0,"In-Stock"),)})
This is responsible for getting the dataset from sheet2:
filter(sheet2!A:B,countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1)
This part gets the instance number of each duplicate value in sheet2!A:A:
countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))
Where there are duplicate values, ">=" gets the one furthest down the sheet. Changing it to "<=" will get the first instance at the top of the sheet.
Within filter, countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1) filters the column to show just 1 instance of each value in sheet2!A:A.
Looking at your example sheet, you have these values in row 6, 7, 8, so the first instance (ascending or descending) will be 0:
1230E 0
1230E 1
1230E 0
If you're looking for a different logic, like 1 trumps 0, then you'll need to apply a sort on the data before performing the vlookup. Something like:
=arrayformula({if(A2:A<>"",substitute(substitute(iferror(vlookup(A2:A,unique(sort(sheet2!A2:B,1,1,2,0)),2,0),"In-Stock"),1,"Issued"),0,"In-Stock"),)})
I have 2 sheets which are connected.
Sheet-1: Has ID column and Status column (Status field is manually updated by the team)
Sheet-2: Has ID column and Status column (+ many other fields)
Requirement: Status column in Sheet 2 to be updated from Sheet-1 if ID column in sheet-2 = ID column in Sheet-1
I wrote a Query and ImportRange, but I could find Query working only when I compare it against a static value (for e.g. Yes). What I want is it to check against the value in ID column from both the sheets and import only for rows that match.
=QUERY(IMPORTRANGE("1ZkPaYb1IIIkcbVerdmZ-Ru1vxFu1YMWj74QNQj2jles", "Ops Action Sheet!B2:B10000"),"select Col2 where Col1 = 'Yes'")
This doesn't directly answer your question about using QUERY, but I believe that that function might not be the best tool for what you're trying to do.
I write below a solution using the alternative function VLOOKUP.
I am assuming here that by "Sheet-1" and "Sheet-2", you actually mean entirely different spreadsheets, judging by your use of IMPORTRANGE.
If you don't mind having a copy of Sheet-1's contents living within Sheet-2, here is what you can do:
On a new sheet (tab) in Sheet-2, copy this function (fill in sheet_1_url):
=IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B")
You should see a copy of the data from Sheet-1 in that tab. You can hide this tab or protect it if you wish.
On your main data tab within Sheet-2, copy this formula in your Status column (assuming that your ID is in A2:
=IFERROR(VLOOKUP($A2,range_from_step_1,2,),)
Copy that formula down as much as you need.
However, if you don't want to have a copy of Sheet-1's data in Sheet-2 for whatever reason, you can simply skip steps 1-2 above, going straight to step 3, with the following formula in Sheet-2:
=IFERROR(VLOOKUP($A2,IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B"),2,),)
Not that I recommend it, since you'd technically be importing your data virtually within the formula N number of times, which will be a huge performance hit.
You can see the references for the formulas used above here:
IMPORTRANGE
VLOOKUP
IFERROR
edit to reflect and paste in spreadsheet 2:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, IMPORTRANGE("ID", "Sheet!A:C"), {2, 3}, 0)))
A2:A - column of IDs in spreadsheet 2
Sheet!A:C - column A of this range hosts IDs
{2, 3} - brings column B and C from spreadsheet 1 into spreadsheet 2