Condtional formatting to highlight duplicates fetching across multiple columns - google-sheets

I have a sheet where I need to highlight the the second duplicates if they are same across multiple columns.
Sl. No. Name Age Target(Millions)
1 ABC 30 2.3
2 DEF 40 1.3
3 ABC 30 4.3
4 GHI 44 0.3
5 JKL 33 6.3
For example the serial number 3 column Name and Age is to be highlighted because its a duplicate of serial 1 Name and Age
Note that not both rows to be highlighted.
I tried with
=AND(countif($B$2:$C,B2)>1, countif($B$2:$C,C2)>1)

This should do it. I made it scalable for if you want to add more columns:
=ROWS(QUERY(ArrayFormula(TO_TEXT(ARRAY_CONSTRAIN($A:$D, ROW()-1, COUNTA(1:1)))), "select "&JOIN(",", ArrayFormula("Col"&({2,3})))&" where "&JOIN(" and ", ArrayFormula("Col"&({2,3})&"='"&ArrayFormula(HLOOKUP(ArrayFormula(VLOOKUP($A$1,$1:$1,({2,3}),0)),$A:$D,ROW(),0))&"'"))))
Readable:
=ROWS(
QUERY(
ArrayFormula(
TO_TEXT(ARRAY_CONSTRAIN(
$A:$D,
ROW()-1,
COUNTA(1:1)
))
),
"select "&
JOIN(
",",
ArrayFormula("Col"&({2,3}))
)&
" where "&
JOIN(
" and ",
ArrayFormula(
"Col"&
({2,3})&"='"&
ArrayFormula(
HLOOKUP(
ArrayFormula(
VLOOKUP(
$A$1,
$1:$1,
({2,3}),
0
)
),
$A:$D,
ROW(),
0
)
)&
"'"
)
)
)
)
Highlight cell if the number of rows with matching cells in previous rows is >0. To add more columns, you'll have to add to every instance of the {2,3}'s. For example, if you want to include D, add a 4 to the arrays.
If you expect to change which columns you want a lot, you can create a separate column elsewhere with the column indexes that you want, then use FILTER in place of the array to save typing.
This highlights any duplicate cell after the original as well.

Related

What Google Sheets formula should I use to average values that are not empty and are unique?

I have the next two tables:
Table 1, on sheet called "top1Data"
Table 2, on sheet called "top1An"
I want to take all the unique champions from Table 1 and insert them into Table 2 (under Total), and then average their stats (kills, solokills).
Note that more champions can be added in the future, so it has to check for non-empty cells.
You can find an editable copy of the Google Sheet here.
Try this in cell B3:
=query(
query(
C2:E,
"select C, sum(D), sum(E)
where C is not null
group by C",
1
),
"select avg(Col2), avg(Col3)
label avg(Col2) '' , avg(Col3) '' ",
1
)

Sheets - Lookup using 3 criteria including variable

Struggling with arrayFormula and vlookup with match to reference data in another sheet tab to pull a percentage based on row and column membership.
I currently have: =ArrayFormula(vlookup(Orange&7,{A1:A&B1:B,C1:E},match("Skill 3",A1:E1,0)-1,0))
In the shared Google sheet, I have placed notes and explanations. This is a reference sheet for a game, where it refers to Hero skills statistics.
MISSION: Using inputted Hero Class "colour" and "Skill Level" get the "percentage" from the appropriate skill column. This will be needed 3 times to cater for the 3 different skill types in question.
Here is the sheet: TEST Sheet
Approach
Creating a VLOOKUP using more than one criteria will require a helper column made by the concatenation of the two(or more) criteria.
In your case you should build a column that concatenates the Color & Level. Your Lookup will search that value and return the corresponding percentage in the 4th column.
Having your table in Hero Lead like this:
+==========================================+
| A | B | C | D | E | F |
+------+-----+-----+-------+-------+-------+
|Lookup|Class|Level|Skill 3|Skill 4|Skill 7|
+------------------------------------------+
You can use this formula to retrieve the correct value of Skill 3
=VLOOKUP("Orange"&7,'Hero Lead'!A:D,4,0)
Just replicate the formula with the other parameter to retrieve the correct percentage level.
Here is a solution:
=IFERROR(
INDEX(
QUERY(
'Hero Lead'!$A$2:$E,
"select C, D, E
where A = '" & $C$36 & "' and
B = " & G36,
-1
),
0,
MATCH(
"Skill " & F36,
'Hero Lead'!$C$1:$E$1,
0
)
),
0
)
This gets you the right skill's boost from the row filtered using QUERY by level and colour.
If you need all three at once for fixed colour and fixed level (in a column thus TRANSPOSE):
=TRANSPOSE(
FILTER(
'Hero Lead'!$C$2:$E,
'Hero Lead'!$A$2:$A = $C$36,
'Hero Lead'!$B$2:$B = G36
)
)
or:
=TRANSPOSE(
QUERY(
'Hero Lead'!$A$2:$E,
"select C, D, E
where A = '" & $C$36 & "' and
B = " & G36,
-1
)
)

I want to populate a new range by inserting numbers between already populated range based on adjusacent cell value

I want to populate a new range and inserting numbers between already populated range based on adjacent cell value.
Eg. if Column A has a range between 1 - 10
and in Column B I entered 3 against the number 4 of Column A
then in Column C a new range should populate splitting 4 into 4a, 4b & 4c as I had entered 3 against it
New list should generate like - 1, 2, 3, 4a, 4b, 4c, 5, 6....
Other examples are entered against no. 7 and 9 of Column A in the image attached.
Screenshot attached below:
try:
=ARRAYFORMULA(QUERY(UNIQUE(REGEXREPLACE(TO_TEXT(UNIQUE(TRANSPOSE(SPLIT(
QUERY(TRANSPOSE(QUERY(TRANSPOSE(A2:A&IFERROR(CHAR(96+SPLIT(IF(B2:B<>"",
REPT("♦1", B2:B), ), "♦")*TRANSPOSE(ROW(INDIRECT("A1:A"&MAX(B2:B))))), ))
,,999^99)),,999^99), " ")))), ".?`$", )), "where Col1 is not null"))
fix for B2 value if 1:
=ARRAYFORMULA(QUERY(UNIQUE(REGEXREPLACE(TO_TEXT(UNIQUE(TRANSPOSE(SPLIT(
QUERY(TRANSPOSE(QUERY(TRANSPOSE(A2:A&IFERROR(CHAR(96+SPLIT(IF(B2:B>1,
REPT("♦1", B2:B), ), "♦")*TRANSPOSE(ROW(INDIRECT("A1:A"&MAX(B2:B))))), ))
,,999^99)),,999^99), " ")))), "\d+`$|`$", )), "where Col1 is not null"))
formula explanation / spreadsheet demo

FILTER and REGEXREPLACE cells with Hyperlinks

I have all the column A with values + Hyperlinks. When I filter these columns, I get only the values of A and miss all the hyperlinks. How Can I keep them?
A B C D
col1 col2 col3 col4
name1 2 3 4
name2 4 6 8
name3 3 5 7
The filter is:
F2 cell:
=ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(IFERROR(FILTER(A:D, C:C="Seen"), " "), "Day on", "Eng. Pending OT"), "Day off", "Eng. Pending OT"))
REGEXREPLACE will kill the hyperlinks so filter needs to be divided into two parts:
=ARRAYFORMULA({ARRAY_CONSTRAIN(IFERROR(FILTER(A:G, C:C="Seen"), ), 999, 1),
REGEXREPLACE(IFERROR(FILTER(B:G, C:C="Seen"), ), "Day on|Day off", "Eng. Pending OT")})

Split 1 column into multiple columns with up to 500 cells each

In Google Sheets, I have a column that is arbitrarily long.
I want to split this column into separate columns of length 500.
How can I do this?
Some things I've been thinking may be involved in a solution:
TRANSPOSE
ARRAY_CONSTRAIN
Arrayformula, an example for number 5, change to 500.
=ArrayFormula(IFERROR(
vlookup(
(TRANSPOSE(ROW(INDIRECT("a1:a"&ROUNDUP(COUNTA(A:A)/5))))-1)*5 + ROW(INDIRECT("a1:a"&5)),
{ROW(A:A),A:A},2,)
))
ROUNDUP(COUNTA(A:A)/5 the number of columns. Up because the last column may contain less than N rows.
TRANSPOSE(...)*5 + ROW(INDIRECT("a1:a"&5)) to get matrix of numbers.
Matrix:
1 6 11 16
2 7 12 17
3 8 13 18
4 9 14 19
5 10 15 20
{ROW(A:A),A:A} to get the number of a row and value to return
vlookup to return a value
IFERROR to show "" if error.
Having an arbitrarily long column implies you'll need arbitrarily many columns for the split, and spreadsheet formulas cannot create new columns. So the best we can is to use all columns available.
Assuming the data column begins with cell A1, and the upper left corner of the range in which it should be split is B1, the following formula will work, if you fill the first 500 rows of the sheet with it:
=offset($A$1, row()-row($B$1) + 500*(column()-column($B$1)), 0)
Otherwise, change A1 and B1 to the top source and upper-left corner of destination.
Explanation: the offset moves from A1 down by the specified amount, which increments by 1 with every row and by 500 with every column.
You could also use this formula:
=ARRAYFORMULA(
TRIM(
SPLIT(
TRANSPOSE(
SPLIT(
QUERY(
<long_column_range> & "," & IF(
MOD(1, <columns>) = 0, "|", ""
),, 9^9
), "|"
)
), ","
)
)
)
where:
<long_column_range> is the range of the long column that you want to split (e.g. A1:A) and
<columns> is the number of columns that you want for the long column to be split into.
Taken from this article.

Resources