Related
Exemple: https://docs.google.com/spreadsheets/d/1o6088xXfnEYn-RflrPvY3e_OGJyrI3-tMIb3tFbm6e8/edit?usp=sharing
I have a question about google sheets, columns id 1 and id 2 have codes that together result in a unique code like column unique id. But, occurs a repetition between columns id 1 and id 2 and I would like to know how to highlight that repetition where the unique id is return. Like in row 3 and 8.
I try something like this:
=QUERY(B3:D10;"select B where "JOIN("",C,D)"="JOIN("",D,C)" ")
=FILTER(C3:D11;CONCAT(C3:D3)=CONCAT(C3:D3))
The expected result is something like line 15 of the example.
To find rows where both IDs are duplicates of IDs found in another row, use filter(), like this:
=let(
data; B3:D11; id_1; C3:C11; id_2; D3:D11;
compoundIds;
map(
id_1; id_2;
lambda(
c; d;
if(c < d; c & "→" & d; d & "→" & c)
)
);
filter(
data;
countif(compoundIds; compoundIds) > 1
)
)
If you do not have the recently introduced let() function yet, use lambda() instead:
=lambda(
data; id_1; id_2;
lambda(
compoundIds;
filter(
data;
countif(compoundIds; compoundIds) > 1
)
)(
map(
id_1; id_2;
lambda(
c; d;
if(c < d; c & "→" & d; d & "→" & c)
)
)
)
)(
B3:D11; C3:C11; D3:D11
)
To highlight duplicates in the list, use this conditional formatting custom formula rule for the range C3:D11:
=len($F3:$F11)
...and fill column F with this formula in cell F3:
=let(
ids; B3:B11; id_1; C3:C11; id_2; D3:D11;
compoundIds;
map(
id_1; id_2;
lambda(
c; d;
if(c < d; c & "→" & d; d & "→" & c)
)
);
map(
ids; compoundIds;
lambda(
id; compoundId;
if(
countif(compoundIds; compoundId) > 1;
id & " = " &
join( ", "; filter(ids; row(ids) <> row(id); compoundIds = compoundId) );
iferror(1/0)
)
)
)
)
...or use the equivalent lambda:
=lambda(
ids; id_1; id_2;
lambda(
compoundIds;
map(
ids; compoundIds;
lambda(
id; compoundId;
if(
countif(compoundIds; compoundId) > 1;
id & " = " &
join( ", "; filter(ids; row(ids) <> row(id); compoundIds = compoundId) );
iferror(1/0)
)
)
)
)(
map(
id_1; id_2;
lambda(
c; d;
if(c < d; c & "→" & d; d & "→" & c)
)
)
)
)(
B3:B11; C3:C11; D3:D11
)
To find rows where id_1 is a duplicate of an id_2 found in the other column in another row, use:
=filter(
B3:C11;
countif(D3:D11; C3:C11)
)
To get the IDs of the duplicates, use vlookup(), like this:
=arrayformula( iferror( vlookup(C18:C; { D3:D11 \ B3:B11 }; 2; false) ) )
To highlight duplicates in the list, use this conditional formatting custom formula rule for the range C3:D11:
=countif($C$3:$D$11; C3) > 1
See your sample spreadsheet.
As shown above, in the event your spreadsheet locale uses comma , as decimal separator, you will have to use semicolon ; as formula argument separator and backslash '\' as { array expression } horizontal separator. If your spreadsheet uses period . as decimal mark, use comma , for both those purposes.
Added solution to your sheet here:
=byrow(C3:D11;lambda(z;JOIN("|";TOROW(SORT(TOCOL(z);1;1)))))
I need to apply solution found in this question:
Using single formula to list unique items, count and sort numerically by descending order and then alphabetically for items with same count
This time adding a data validation menu for the search period.
I can do this for single cell but I'm not able to apply it to the solution above.
Formula for search period is this:
=COUNTIFS($B3:$B,"*apple*",$A3:$A,">="&TODAY()- VLOOKUP(
SUBSTITUTE(D2," ",""),
{"24HOURS",0;
"2DAYS",1;
"3DAYS",4;
"7DAYS",7;
"2WEEKS",14;
"1MONTH",30;
"3MONTHS",90;
"6MONTHS",180;
"1YEAR",365;
"2YEARS",730;
"3YEARS",1095;
"TOTAL",999999},
2,FALSE))
Formula taken from solution on question above:
=QUERY(B:B,"Select B, count(B) where B matches '^(?!(?:ITEMS|ExcludeB|ExcludeC)$).+' group by B order by count(B) DESC label count(B) ''")
Image to help clarify:
My dummy file:
https://docs.google.com/spreadsheets/d/1iB4BnqhTBVNuCCQ4GnEIu95gbzYb0T9H9A3Pi1W5AZk/edit?usp=sharing
Is such a thing possible? Any pointers on how this can be done? Thank you
In Excel (since you tagged it) you can use the following in Office 365:
=LET(a,A2:INDEX(B:B,LOOKUP(2,1/(A:A<>""),ROW(B:B))),
aa,INDEX(a,,1),
ab,INDEX(a,,2),
u,UNIQUE(INDEX(a,,2)),
c,COUNTIF(ab,u),
d,COUNTIFS(ab,u,
aa,">="&TODAY()
-VLOOKUP(SUBSTITUTE(D2," ",""),
{"24HOURS",0;
"2DAYS",1;
"3DAYS",4;
"7DAYS",7;
"2WEEKS",14;
"1MONTH",30;
"3MONTHS",90;
"6MONTHS",180;
"1YEAR",365;
"2YEARS",730;
"3YEARS",1095;
"TOTAL",999999},
2,0)),
SORT(CHOOSE({1,2,3},u,c,d),{2,1,1},{-1,1,1}))
This should do it.
=QUERY(
A:B,
"Select B, count(B)
where
B matches '^(?!(?:ITEMS|ExcludeB|ExcludeC)$).+' and
A >= date '"&
TEXT(
IFERROR(
VLOOKUP(
D2,
{"2 4 H O U R S",TODAY()-1;
"3 D A Y S",TODAY()-3;
"7 D A Y S",TODAY()-7;
"2 W E E K S",TODAY()-14;
"1 M O N T H",EDATE(TODAY(),-1);
"3 M O N T H S",EDATE(TODAY(),-3);
"6 M O N T H S",EDATE(TODAY(),-6);
"1 Y E A R",EDATE(TODAY(),-12);
"2 Y E A R S",EDATE(TODAY(),-24);
"3 Y E A R S",EDATE(TODAY(),-36)},
2,FALSE),0),"yyyy-mm-dd")&"'
group by B
order by
count(B) DESC,
B asc
label count(B) ''")
Using an array
=QUERY(
{A3:A,E3:E},
"Select Col2, count(Col2)
where
Col2 matches '^(?!(?:ITEMS|ExcludeB|ExcludeC)$).+' and
Col1 >= date '"&
TEXT(
IFERROR(
VLOOKUP(
G2,
{"2 4 H O U R S",TODAY()-1;
"3 D A Y S",TODAY()-3;
"7 D A Y S",TODAY()-7;
"2 W E E K S",TODAY()-14;
"1 M O N T H",EDATE(TODAY(),-1);
"3 M O N T H S",EDATE(TODAY(),-3);
"6 M O N T H S",EDATE(TODAY(),-6);
"1 Y E A R",EDATE(TODAY(),-12);
"2 Y E A R S",EDATE(TODAY(),-24);
"3 Y E A R S",EDATE(TODAY(),-36)},
2,FALSE),0),"yyyy-mm-dd")&"'
group by Col2
order by
count(Col2) DESC,
Col2 asc
label
Col2 '',
count(Col2) ''")
I have the following ARRAYFORMULA entered into cell D2, and it seems like it should be expanding downward throughout the entire column (I'll do the "check for blank A2" addition to the formula once this part works correctly), but nothing is expanding. Where have I gone astray?
Here's the formula:
=ArrayFormula(IFERROR(QUERY('Form Responses 1'!$A:$J,"select count(E) where (C contains '"& $A2:A &"' or C contains '"& $B2:B &"') and (E) Contains 'Option' label count(E) ''"),0)+
IFERROR(QUERY('Form Responses 1'!$A:$J,"select count(F) where (C contains '"& $A2:A &"' or C contains '"& $B2:B &"') and (F) Contains 'Option' label count(F) ''"),0)+
IFERROR(QUERY('Form Responses 1'!$A:$J,"select count(G) where (C contains '"& $A2:A &"' or C contains '"& $B2:B &"') and (G) Contains 'Option' label count(G) ''"),0)+
IFERROR(QUERY('Form Responses 1'!$A:$J,"select count(H) where (C contains '"& $A2:A &"' or C contains '"& $B2:B &"') and (H) Contains 'Option' label count(H) ''"),0)+
IFERROR(QUERY('Form Responses 1'!$A:$J,"select count(I) where (C contains '"& $A2:A &"' or C contains '"& $B2:B &"') and (I) Contains 'Option' label count(I) ''"),0))
A link to a copy of the spread follows:
https://docs.google.com/spreadsheets/d/14E1QEfcTYiwOG_gORkc8YoRuWEPM7FweLljj0hQCQTc/edit?usp=sharing
try:
=ARRAYFORMULA(IF(TRIM(B2:B)="",,IFNA(IFNA(VLOOKUP((B2:B),
QUERY({IFNA(IFNA(REGEXEXTRACT('Form Responses 1'!C2:C, "\b"&TEXTJOIN("\b|\b", 1, (B2:B))&"\b"),
REGEXEXTRACT('Form Responses 1'!C2:C, "\b"&TEXTJOIN("\b|\b", 1, TRIM(A2:A))&"\b"))),
MMULT(N(REGEXMATCH('Form Responses 1'!E2:I, "(?i)Option")), {1;1;1;1;1})},
"select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2)''"), 2, 0), VLOOKUP(TRIM(A2:A),
QUERY({IFNA(IFNA(REGEXEXTRACT('Form Responses 1'!C2:C, "\b"&TEXTJOIN("\b|\b", 1, (B2:B))&"\b"),
REGEXEXTRACT('Form Responses 1'!C2:C, "\b"&TEXTJOIN("\b|\b", 1, TRIM(A2:A))&"\b"))),
MMULT(N(REGEXMATCH('Form Responses 1'!E2:I, "(?i)Option")), {1;1;1;1;1})},
"select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2)''"), 2, 0)), 0)))
UPDATE:
=ARRAYFORMULA(IF(C2:C="",,IFNA(IFNA(VLOOKUP(B2:B, QUERY({TRIM(FLATTEN(QUERY(TRANSPOSE(
REGEXEXTRACT('Form Responses 1'!C2:C, TEXTJOIN("|", 1, "("&SUBSTITUTE(TRIM(UNIQUE(
FILTER({Sheet3!B2:B; Sheet3!A2:A}, {Sheet3!B2:B; Sheet3!A2:A}<>""))), " ", ").+(")&")"))),,9^9))) ,
MMULT(N(REGEXMATCH('Form Responses 1'!E2:I, "(?i)Option")), {1;1;1;1;1})},
"select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2)''"), 2, 0),
VLOOKUP(A2:A, QUERY({TRIM(FLATTEN(QUERY(TRANSPOSE(
REGEXEXTRACT('Form Responses 1'!C2:C, TEXTJOIN("|", 1, "("&SUBSTITUTE(TRIM(UNIQUE(
FILTER({Sheet3!B2:B; Sheet3!A2:A}, {Sheet3!B2:B; Sheet3!A2:A}<>""))), " ", ").+(")&")"))),,9^9))) ,
MMULT(N(REGEXMATCH('Form Responses 1'!E2:I, "(?i)Option")), {1;1;1;1;1})},
"select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2)''"), 2, 0)), 0)))
https://docs.google.com/spreadsheets/d/e/2PACX-1vT0X3Lky90cnTWg6RLr-J8NotNbj9-LACD0U4S0j3yhBEm6hlZEajdaIJ_OIUBZcstRlMkZqk5Ccuaq/pubhtml?gid=845418160&single=true
I have a google sheet like the above link it looks like this
Timestamp Exact Username of Hacker Video Link
6/30/2020 1:55:21 Column1DummyData
6/30/2020 1:59:09 Column1DummyData
6/30/2020 1:59:14 Column1DummyData
6/30/2020 1:59:19 Column1DummyData
6/30/2020 2:59:31 Svd
6/30/2020 2:59:37 Svd
6/30/2020 10:38:15 qwerty
6/30/2020 10:44:15 test https://www.youtube.com/watch?v=3UZzu4UQLcI
6/30/2020 10:58:53 test https://www.youtube.com/watch?v=HbgzrKJvDRw
6/30/2020 10:59:33 test https://www.youtube.com/watch?v=gxpX_mubz2A
I managed to make an output like this using the query:
*=ARRAYFORMULA({
QUERY(B3:B, "select B,count(B) where B !='' group by B label count(B)''"), IFNA(VLOOKUP(
QUERY(B3:B, "select B,count(B) where B !='' group by B label count(B)''"), {
QUERY(B3:C, "select B,count(B) where B !='' and C !='' group by B label count(B)''"),
REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IF(QUERY(
QUERY(B3:C, "select count(B) where B !='' and C !='' group by B pivot C"),
"offset 1", 0)="",,QUERY(
QUERY(B3:C, "select count(B) where B !='' and C !='' group by B pivot C"),
"limit 0", 1)&",")),,99^99))), ",$", )}, 3, 0))})*
OutPut
Name NumberOfItem Video link
Column1DummyData 4
Svd 2
qwerty 1
test 3 https://www.youtube.com/watch?v=3UZzu4UQLcI, https://www.youtube.com/watch?v=HbgzrKJvDRw, https://www.youtube.com/watch?v=gxpX_mubz2A
But I need the output to be sorted in descending order based on NumberOfItem Column
use:
=ARRAYFORMULA(QUERY({
QUERY(B2:B, "select B,count(B) where B !='' group by B label count(B)''"), IFNA(VLOOKUP(
QUERY(B2:B, "select B,count(B) where B !='' group by B label count(B)''"), {
QUERY(B2:C, "select B,count(B) where B !='' and C !='' group by B label count(B)''"),
REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IF(QUERY(
QUERY(B2:C, "select count(B) where B !='' and C !='' group by B pivot C"),
"offset 1", 0)="",,QUERY(
QUERY(B2:C, "select count(B) where B !='' and C !='' group by B pivot C"),
"limit 0", 1)&",")),,99^99))), ",$", )}, 3, 0))}, "order by Col2 desc", 0))
How to get values from another sheet if another cell empty. I'm trying to get values from sheet1 column B if in sheet1 column H empty.
I mean if Sheet1 column B2 to B4 have values and in Column H on the same sheet, if H2 and H3 have text only B4 value print.
Sheet1 Image
Sheet2 Image
Here is what I try to do that not work
=query(Sheet1!B2:B, "Select Sheet1!b where Sheet1!H <> ''")
try:
=FILTER(Sheet1!B2:B, Sheet1!B2:B<>"", Sheet1!C2:C="")
or:
=QUERY(Sheet1!B2:C, "select B where B is not null and C is null", 0)
or:
=QUERY(Sheet1!B2:C, "select B where B !='' and C =''", 0)