How to prevent duplicates between two different sheets on google sheets? - google-sheets

I have 2 sheets, one is sheet1, other is sheet2.
Data in sheet1
Name
A
B
C
D
E
L
M
N
O
P
Data in sheet2
Name
F
G
D
H
G
Here in sheet2, two data is duplicated. One is "D" compared to sheet1, other is "G" in same sheet2.
I want to prevent duplication in both these cases so that whenever I enter new value in sheet 2, it must check both the sheets and reject duplicate entries.
I am using Google Sheet, and using data validation with a custom formula =COUNTIF(sheet1!A2:A&sheet2!A2:A,Sheet2!A2)<2
But, it's not working. Please help me.

Try with:
=COUNTIF({sheet1!$A2:$A;sheet2!$A$2:$A},Sheet2!A2)>1
With curly brackets you can join the ranges

Related

Google Sheets formula to lookup value for all rows in another sheet by column names and returning value by column name

I have a Sheet1 with data like this:
one
two
three
four
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
I have Sheet2 with data like this:
alpha
value 1
c
k
g
c
For each row in Sheet2, I want to look up Sheet2.A2:A in Sheet1 according to a lookup column name in Sheet1 and returning values from the associated row in Sheet1 by return column name in Sheet1.
So, a few examples:
Lookup Sheet2.A2:A in Sheet1.three and return Sheet1.one
Lookup Sheet2.A2:A in Sheet1.two and return Sheet1.four
The idea is the formula would specify the lookup column name and return column name and I'd just change it for each lookup I need to do.
Imagine the formula was something like:
=ARRAYFORMULA(
SOMEFORMULA(
A2:A, # lookup this value
GETCOLUMN(Sheet1, "three"), # in this column in Sheet1
GETCOLUMN(Sheet1, "one") # and return the value from this column in Sheet1
)
)
So, the expected result is:
alpha
value
c
a
k
i
g
e
c
a
I can use the new Google Sheet formulas they just released -- except named ranges. I feel like there is some clever trick using them, but I can't come up with it.
Give a try on below formula:
=BYROW(A2:INDEX(A2:A,COUNTA(A2:A)),LAMBDA(x,INDEX(Sheet1!A:D,MATCH(x,INDEX(Sheet1!A:D,,MATCH("three",Sheet1!A1:D1,0)),0),MATCH("one",Sheet1!A1:D1,0))))
By XLOOKUP() function.
=BYROW(A2:INDEX(A2:A,COUNTA(A2:A)),LAMBDA(x,XLOOKUP(x,FILTER(Sheet1!A2:D,Sheet1!A1:D1="three"),FILTER(Sheet1!A2:D,Sheet1!A1:D1="one"),"")))
Sample Sheet Link.
Use HLOOKUP to the get the correct column in Sheet1 and XLOOKUP to get the corresponding column A value:
=ARRAYFORMULA(
XLOOKUP(
A2:INDEX(A2:A,COUNTA(A2:A)),
HLOOKUP("three",Sheet1!A1:Z,SEQUENCE(ROWS(Sheet1!A1:Z)),0),
Sheet1!A1:A
)
)

VLookup Displaying Duplicate Values - Google Sheets

I've created a lookup formula to take values from column E, match them with values in column A, and assign the corresponding value found in column C and populate it in column F.
I've checked for duplicates in E and A, but I'm still seeing duplicates in F. It's not because there isn't a match, I've checked that as well.
My formula is:
=LOOKUP(E2, $A$2:$A$121, $C$2:$C$121)
Here is a simplified version of the spreadsheet: https://docs.google.com/spreadsheets/d/1A-S0nHFIUGycaDo7KDPAzWBwRZQmfxkjaMivwGfBh-8/edit?usp=sharing
delete everything in F column and use in F2:
=INDEX(IFNA(VLOOKUP(E2:E, A:C, 3, 0)))

Grouping Data with SUM of Value No Greater than a Specific Number (Google Sheets)

I have series of numbers as you can see in the following table in a Google Spreadsheet:
I want each name to form a group with other names next to it with sum of value no more than 26. If a sum is greater than 26, then it will be just forced to form to another group with another name.
So that it might look like this:
In this example, A and B can form a group together since the total sum of A and B is no more than 26. C is forced to form a group just by itself since if we add D with C, the sum will be more than 26. D is also forced to form a group just by itself since if we add D with E, the sum will be more than 26.
How can I create a table with Array Formula so it looks like that?
This is the link for the sample case:
https://docs.google.com/spreadsheets/d/1BXfJrfbtdsGP4fr9dsKxFq54nM4PnKLHauAOy5UAPbY/edit#gid=0
The sample case is in Sheet2
Column A and B are given condition
Column D to G are the desired outcome
Edited: sample case is changed from Sheet1 to Sheet2 so that the problem can be seen more clearly. Sheet1 is hidden to prevent confusion.
You can do it using two formulas:
for group in col G =ArrayFormula(IF(B2:B,INT(MMULT(TRANSPOSE((ROW(B2:B)<=TRANSPOSE(ROW(B2:B)))*B2:B),SIGN(B2:B))/26)+1,))
for group sum in col F =ArrayFormula(IF(LEN(B2:B),SUMIF(G2:G,G2:G,B2:B),))
or using one formula in col F which will be slower:
=ArrayFormula(IF(LEN(B2:B),{SUMIF(INT(MMULT(TRANSPOSE((ROW(B2:B)<=TRANSPOSE(ROW(B2:B)))*B2:B),SIGN(B2:B))/26)+1,INT(MMULT(TRANSPOSE((ROW(B2:B)<=TRANSPOSE(ROW(B2:B)))*B2:B),SIGN(B2:B))/26)+1,B2:B),INT(MMULT(TRANSPOSE((ROW(B2:B)<=TRANSPOSE(ROW(B2:B)))*B2:B),SIGN(B2:B))/26)+1},))

Improve Query Function in Google Sheets

I've been using the following function:
=query(Sheet1!A2:D," select A, B, C where A matches '"&JOIN("|", A2:A)&"' and D matches 'yes'")
Is there anyway that I can make is so that every row that starts with a match will be added a comma separated list in which each column occupies one cell with no duplicates as shown in sheet3.
https://docs.google.com/spreadsheets/d/1YDxIUnZzzYde9hcexPoDegv4HBuiUwk2wLKSXazu9hE/edit?usp=sharing
Sheet 2 has the function that I used and the result.
It is not entirely clear what you want to do, but try this. In Sheet1 in E2 put this combining Col A and D:
=arrayFormula(A2:A & if(isBlank(D2:D),""," ") & D2:D)
In F2 combine Col C and D with this:
=arrayFormula(B2:B & if(isBlank(C2:C),"",",") & C2:C)
In G2 find the unique values from Col F with this:
=UNIQUE(E2:E)
In H2 put this and drag the formula down:
=join(",",query(E2:F,"select F where E contains '"& G2 &"'"))
Hide Cols E & F

Spreadsheet Sorting Function

I want to only grab certain values from a column and put them in another column. Here is a graphic of what we would want the output to be. I am using Google Sheets.
Example of what I am trying to do:
Help of any kind would be appreciated
This is achieved with the filter formula. If in D2 you have
=filter(B2:B, A2:A = "A")
that column will contain the entries from column B where the corresponding column A entry is "A". Similarly for others.
Use query. In D2, E2, F2 put:
=query(A2:B,"select B where B contains 'A'")
=query(A2:B,"select B where B contains 'B'")
=query(A2:B,"select B where B contains 'C'")

Resources