Need Help getting the unique values - google-sheets

I would like to get the unique values using query function in google sheets
Col1
Col1
Col3
Col4
A
1
12
111
A
2
13
222
A
2
14
333
B
3
15
444
B
3
16
555
B
4
17
666
enter image description here
I would like to get the output like below
Col1 Col2 Col3 Col4
A 1 12 111
A 2 13 222
14 333
B 3 15 444
16 555
4 17 666
enter image description here

use:
=ARRAYFORMULA({IF(COUNTIFS(A1:A&B1:B, A1:A&B1:B,
ROW(A1:A), "<="&ROW(A1:A))=1, A1:B, ), C1:D})

Related

How do I sum the cells of one column based on unique duplicate rows of other columns?

I need column D summed wherever column A-C are identical. Column E is what I want the output to look like. I am only using google sheet functions right now and have not learned how to write script. This formula is the closest I've gotten.
=SUM(filter(D:D;COUNTIF(A2:A&B:B&C:C;A2:A&B:B&C:C)>1))
However, it does not distinguish between different text strings only sums any duplicate.
Thanks for any help!
A
B
C
D
E
papaya
10/10/2022
500
42
42
papaya
15/12/2022
550
30
59
papaya
15/12/2022
550
29
59
Pineapple
16/11/2022
400
55
55
Pineapple
09/11/2022
400
63
78
Pineapple
09/11/2022
400
15
78
use:
=QUERY(A:E; "select A,B,C,sum(D) where D is not null group by A,B,C label sum(D)''")
update
use in M2:
=INDEX(LAMBDA(bc; g; i; IFERROR(g/VLOOKUP(bc; QUERY({bc\i*1};
"select Col1,sum(Col2) where Col2 > 0 group by Col1 label sum(Col2)''"); 2; )))
(B2:B&C2:C; G2:G; I2:I))

Horizontal Lookup using Index Match on Google Sheets

For the following image from Google Sheets, I want to fill out column L with the value found in column A "PPID" based on values in column J "ID" and referencing the range columns B-I. For example, the value "123" should be filled out in column L for the IDs in column J that are 981296581, 682975586, etc. I tried using Index-Match formula, such as =INDEX($A$3, MATCH(J3,B3, 0)), but it only worked for the first row of data and showed an error for the remaining rows
Here is the screenshot of my Google Sheets, as well as the tables below it if you need to copy it into your Google Sheets:
SHEET 1
PPID
ID
ID
ID
ID
ID
ID
ID
ID
123
981296581
682975586
6144233
6140531
6047231
4540543
134
34
456
815220681
1532839
1141531
SHEET 2
ID
INTENDED RESULT
COLUMN TO FILL OUT (with formula)
981296581
123
682975586
123
6144233
123
6140531
123
6047231
123
4540543
123
134
123
34
123
815220681
456
1532839
456
1141531
456
Thanks!
The format isn't really conducive for a lookup. We can FLATTEN the key range and "repeat and flatten" the value range(with IF) to make it conducive for any lookup.
=ARRAYFORMULA(
XLOOKUP(
K2:K12,
FLATTEN(B2:I3),
FLATTEN(IF(COLUMN(B2:I3),A2:A3,))
)
)
ID(K1)
INTENDED RESULT
COLUMN TO FILL OUT (with formula)
981296581
123
123
682975586
123
123
6144233
123
123
6140531
123
123
6047231
123
123
4540543
123
123
134
123
123
34
123
123
815220681
456
456
1532839
456
456
1141531
456
456
try:
=INDEX(IFERROR(VLOOKUP(J3:J, IFERROR(SPLIT(FLATTEN(
IF(B3:I="",,B3:I&"×"&A3:A)), "×")), 2, 0)))
Use this
=ArrayFormula(IF(A3="",,
BYROW(B3:I3, LAMBDA(l, IF(ARRAY_CONSTRAIN(QUERY(
TRANSPOSE(REGEXMATCH(J3&"",l&"")), "Select Col1 where Col1 = TRUE"),1,1)<>TRUE,,A3)))))

Add cell on different sheet when the adjacent is equal to another cell

I have 2 sheet2 on the same file:
the first collect the answers of different trial judge and the second should make the total
Like this:
First sheet
Name q1 q2 q3 total judge_id
Bob 1 5 8 14 1
Jeff 2 4 2 8 1
Bob 3 1 4 8 2
Bob 5 3 2 10 3
Jeff 6 1 8 15 3
Second sheet
judge_id 1 2 3 tot
Bob 14 8 15 37
Jeff 8 # 15 23
How can I sum only the row on a 'person' in particolar?
There is a fast way to do it without open Google Script?
try:
=ARRAYFORMULA({QUERY({A2:F},
"select Col1,sum(Col5) where Col1 is not null group by Col1
pivot Col6 label Col1'judge_id'"), {"tot"; MMULT(QUERY(QUERY({A2:F},
"select sum(Col5) where Col1 is not null group by Col1 pivot Col6"),
"offset 1", )*1, SEQUENCE(COUNTUNIQUE(F2:F), 1, 1, ))}})
Here's my take on it:
={
QUERY(A1:F,"SELECT A, SUM(E) WHERE A IS NOT NULL GROUP BY A PIVOT F LABEL A 'Judge ID'"),
QUERY(A1:F,"SELECT SUM(E) WHERE A IS NOT NULL GROUP BY A")
}

How to combine two tables with common headers in google sheets?

I am trying to combine two tables with common headers. The formula below only properly works, if I define the exact start and end row. How can I adjust the formula below to dynamically fetch non blank rows from both the tables.
=iferror({A1:C50;ArrayFormula(hlookup(A1:C1,'Settings'!A1:C50,row(A2:A50),0))})
Sample Input:
Table 1
col 1
col2
col 3
abc
123
789
def
456
1212
Table 2
col 1
col2
col 3
abc
123
78849
jkl
256
1298
Desired Output:
Table 3
col 1
col2
col 3
abc
123
789
def
456
1212
abc
123
78849
jkl
256
1298
Use OUERY:
=QUERY({A1:C1;A2:C;E2:G},"WHERE Col1 IS NOT NULL")

Calculate average from a list with duplicate entries

I have 2 google sheets I'm working off. The master and a copy to create a 'dashboard' for analytics.
Master Sheet
name
quantity
price/quantity
RozMo
10
1.75
Tam
3
3.65
Gurba
36
12
Tam
30
0.55
RozMo
25
0.75
RozMo
5
0.50
RozMo
2
0.35
Gurba
150
8.75
Dashboard Sheet - Desired Output
name
quantity
price/quantity
RozMo
42
0.939
Tam
33
0.831
Gurba
186
9.379
Dashboard Sheet - This is how far I've got
name
quantity
price/quantity
RozMo
42
Tam
33
Gurba
186
Formulae used
To get the unique names
=UNIQUE('Master Sheet'!$A$2:$A)
To get quantity
=SUMIFS('Master Sheet'!$B$2:$B,'Master Sheet'!$A$2:$A,A2)
How do I populate the third column?
See how this works for you (I cannot test it, since you did not provide access to the spreadsheet):
=ArrayFormula(QUERY({'Master Sheet'!A2:C,'Master Sheet'!B2:B*'Master Sheet'!C2:C},"Select Col1, SUM(Col2), SUM(Col4)/SUM(Col2) WHERE Col1 Is Not Null GROUP BY Col1 LABEL Col1 'name', SUM(Col2) 'quantity', SUM(Col4)/SUM(Col2) 'price/qty' FORMAT SUM(Col4)/SUM(Col2) '0.000'"))
This one formula should produce all headers and results, formatted according to your full "desired result." If not, share a link to your spreadsheet (or a copy of it).

Resources