Hi have something how this.
COLUMN_NAME
------------
NAME1
NAME2
NAME3
NAME1
NAME1
NAME4
NAME2
I want to get the most repeated value from this colum, on this case, NAME4, any can help me? I tried some query functions but I dont understand the correct logic for this :S
First of all, if I'm not mistaken in the above example the most repeated text is "NAME1", since it occurs 3 times.
I'm sure that there is a better solution for the problem, but I only figured out this:
=index(query(A1:B8,"select A,count(B) where B ='' group by A order by count(B) desc",1),2,1)
NOTE: The quotes after B ='' are two simple quotes, not double quotes!! At that point we are comparing the B column with the empty string.
Supposing that:
The raw data should be in A2:A8 cells (NAME1, NAME2, NAME3, ...)
There is an "extra" column we use, next to A (column B). All cells should be empty.
The above formula first runs a query (see the QUERY function inside) in which we count the occurences of each text and we are ordering by the count number in descending order. We will get something like this:
Column_name count
NAME1 3
NAME2 2
NAME3 1
NAME4 1
Then - with the index function - we get the cell value which is in the 2nd row and 1st column of the result of the query. This will be always good, because we always sort (=order by) the query results in descending order. So the most repeated text will always be in that position.
So it's a workaround, not that pretty, but works.
Hope it helped anyway.
Related
Repeated rows maybe easy to filter but is there to remove repeated INVERTED rows from different columns in google sheets. Maybe it is easy but I've not had much luck so far with "unique" or "filter". The attached image should show what I'm looking to accomplish. Unique alone doesn't work because the second column (I)includes names from (H). So sheets looks at both columns as unique and returns them all. But this is like wanting to remove repeated first and last names, where the names might be inverted.
On the right is the result I'd like to achieve. Leaving only ONE match that would include the numeric values.
Appreciate any feedback. Thanks. 🙏
Get row number MATCH Name1 in Name2 Col. Get row number MATCH Name2 in Name1 Col. See if they are equal and whether the first MATCH is greater than or equal to the current row number.
=FILTER(A2:B7,IFNA(XMATCH(A2:A7,B2:B7)>=ROW(A2:A7)*(XMATCH(A2:A7,B2:B7)=XMATCH(B2:B7,A2:A7)),1))
Name1
Name2
Results
John
Doe
John
Doe
Dan
Jove
Dan
Jove
Doe
John
Jack
Tyler
Jack
Tyler
Jove
Dan
Doe
John
Another method would be to SORT BYROW and UNIQUE
I'm trying to get the product and amount info for Alex (as in attached). However, if Alex has got any product with the amount showing as zero shouldn't be picked up.
What query or formula should I go with on g-sheets?
You can use FILTER function with 2 conditions
Speaking english:
Show column with products and numbers
Column with numbers is not 0
Column with names is Alex
=filter(C2:D,B2:B=F2,D2:D<>0)
You can also do it using QUERY formula:
=query(B2:D,"select C,D where B = '"&F2&"' and D <> 0")
F2 is a cell where you put name
This a simple customer sheet:
A B C D
ID First Middle Last
1 John Doe
2 Jane Maia Doe
And in F1 I put this vlookup code:
=VLOOKUP($G$1;$A$1:$D$3;2;FALSE)&" "&VLOOKUP($G$1;$A$1:$D$3;3;FALSE)&" "&VLOOKUP($G$1;$A$1:$D$3;4;FALSE)
When I lookup ID 2, it's perfect nicely spaced between the vlookups
But when I lookup ID 1 you see 2 spaces between the first and last name, because there is no middle name here.
How can I manage that I always see 1 space between the vlookups?
One way you could achieve the result you're looking for is to simply replace multiple spaces with a single space.
=REGEXREPLACE(JOIN(" ",ARRAYFORMULA(VLOOKUP(G1,A:D,{2,3,4},FALSE))),"\s{2,}"," ")
This formula looks up G1 in your table (A:D). VLOOKUP can be used in an ARRAYFORMULA to efficiently retrieve all of the columns you want in one shot. Your JOIN joins all of the retrieved columns, inserting a space between each value. Finally, your REGEXREPLACE function looks for multiple consecutive spaces and replaces them with a single space.
Alternatively, you could filter the resulting array (i.e. the result of what your VLOOKUP returns). The following formula looks up the array of first, middle, and last name, and then filters out any empty cells before joining the remaining elements with a space.
=JOIN(" ",FILTER(VLOOKUP(I1,A:D,{2,3,4},FALSE),INDIRECT("B"&MATCH(I1,A:A,0)&":D"&MATCH(I1,A:A,0))<>""))
all you need is TRIM fx and:
=ARRAYFORMULA(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(
VLOOKUP(G1:G2, A1:D3, {2,3,4}, 0))),,999^99))))
I am trying to conditionally format a row in Google Sheets based on the result of a QUERY operation. I can get the QUERY to return the value I want (either 0 or non-zero), however QUERY insists on returning a header row.
Since the QUERY now takes up 2 rows for every row of data, changing the format of the row based off the QUERY result starts to get weird after just a few rows.
The problem I am ultimately trying to solve in the case where I enter a list of names, and I want to compare each name to a list of "NSF Names". If a name is entered, and it exists on the NSF list, I would like to flag the entry by highlighting the row red.
Help is greatly appreciated.
Edit: Formula, as requested:
=query(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"'")
A:D is the data set (A is a numeric ID, B is full name, C and D are first and last names respectively).
E1 and E2 are placeholders for the person's first and last name, but would eventually be replaced with parsing the person's name, as it's inputted on the sheet (TRIM(LEFT(" ", A2) etc...)
I can get the QUERY to return the value I want (either 0 or non-zero),
however QUERY insists on returning a header row.
There might be better ways to achieve what you want to do, but in answer to this quote:
=QUERY(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"' label count(A) ''")
A query seems a long-winded approach (=countifs(C1:C7,E$1,D1:D7,E$2) might be adequate) but the label might be trimmed off it by wrapping the query in:
index(...,2)
I have the following Google Sheets data:
Name1 Name2 Name3 Value
A B C 20
B A C 30
C D F 40
What I'm trying to do is see if a specific name appears in any of the three name columns. If it does, then sum all the values in the "Value" column for all matching rows.
For example, I want to sum all of the values for name "A". That name only appears on the first two rows, so it should do 20+30 to give me 50. If I change the searched name to "C", that appears in all three rows so it should sum all of the numbers: 20+30+40. The algorithm needs to adjust and search appropriately.
=DSum will work
With the example you give use
=dsum(A1:D4,D1,{A1;"A"})+dsum(A1:D4,D1,{B1;"A"})+dsum(A1:D4,D1,{C1;"A"})
You can swap the "A" for a Cell reference
see https://drive.google.com/previewtemplate?id=0As3tAuweYU9QdEVHdTFHNzloSTY4LVYxdW9LdHRHbEE&mode=public#