Is there a function to check the same value in range? - if-statement

I am using google sheets and I have a query that if the value in the range is the same then write something. If at least value is other from rest. Can somebody have an idea how to bite this topic?
I was trying to use
=if(A2:C2="Something";"YES";"NO")
=if(A2="Something" AND B2="Something";"YES";"NO")

You could try something like:
if(column(range)*row(range)=countif(range;index(range;0;0);"YES";"NO")
The first part calculates the number of cells in the range, the second calculates the
number of values equal to the value in the first cell.
You can replace the condition by changing index(range;0;0) to for example "Something", if you want to match a literal.

=ARRAYFORMULA(IF(A1:A<>""; IF(COUNTIF(A1:A; A1:A)>1; "yes"; "no"); ))

Related

Regular Expression - Extract Words and number

So I'm using Regexextract in GoogleSheet to find the value for a big amount of data. I have 2 problems I don't know to extract or what I did wrong. Feel free to point out my mistakes and help me with a solution.
Require: I need to extract the part number which format is ABCD#### or ABCD-#### which is is Upper character and numbers follow after, with or w/o "-" , for example KTA1763 or SPD-4124
# I use this formula: =Regexextract(A1,"([A-Z]+-?[0-9]*)") .FYI, the values I'm extracting, it could appear either at the beginning, middle or last.
1.First problem, I have the value as below:
REACH TECH 223/224 list document for KTD2026BEWE-TR
=> Extract result : REACH
[What I need: KTD2026]
2.I have the value as:
information for Part number KTA1550EDS-TR
=> Extract result: P
[What I need: KTA1550]
Please let me know which part in the formula should I fix to have the final expected result. Or how should I alter my formula for that matter, big thanks
go for:
=INDEX(IFNA(REGEXEXTRACT(A1:A, "[A-Z]+\d+")))
Try this in one cell.
=ArrayFormula(IF(A2:A="",,REGEXEXTRACT(REGEXEXTRACT(A2:A, ".+"&REGEXEXTRACT(A2:A, "[0-9]+")), ".+\s(.+)")))

Convert text to numeral text

I have a google spreadsheet that I am using as a quiz. The quiz takers select an option from a data validation drop down.
The cell below strips all but the first character =left(A2,1) which is a numeral value. Further below in the sheet is a cell that sums certain cells, For instance,
=Sum(A3,D3)
For some reason, the sum function does not recognize the cell as a purely numeral value, even with changing the format to number. Any ideas?
you can use SUMPRODUCT instead of SUM which is able to recognize numeric values even if they are disguised as a text string:
=SUMPRODUCT(A3:D3)
another way would be use regex like:
=ARRAYFORMULA(REGEXEXTRAXT(A3:D3, "(\d+)-")*1)
Given what is immediately above the values in Row3, that row might be redundant and the total calculated as:
=ArrayFormula(sum(0+left(A2:D2)))

Best way to show blank cell if value if zero

=COUNTIFS(Orders!$T:$T,$B4)
is a code that gives 0 or a +ve result
I use this across 1500 cells which makes the sheet gets filled with 0s
I'd like to remove the Zeros by using the following formula
if(COUNTIFS(Orders!$T:$T,$B3,Orders!$F:$F,""&P$1&"*")=0,
"",
COUNTIFS(Orders!$T:$T,$B3,Orders!$F:$F,""&P$1&"*"))
This calculates every formula twice and increases the calculation time.
How can we do this in 1 formula where if the value is 0 - keep empty - otherwise display the answer
I suggest this cell-function:
=IFERROR(1/(1/COUNTIFS(Orders!$T:$T,$B4)))
EDIT:
I'm not sure what to add as explanation. Basically to replace the result of a complex calculation with blank cells if it results in 0, you can wrap the complex function in
IFERROR(1/(1/ ComplexFunction() ))
It works by twice taking the inverse (1/X) of the result, thus returning the original result in all cases except 0 where a DIV0 error is generated. This error is then caught by IFERROR to result in a blank cell.
The advantage of this method is that it doesn't need to calculate the complex function twice, so can give a significant speed/readability increase, and doesn't fool the output like a custom number format which can be important if this cell is used in further functions.
You only need to set the number format for your range of cells.
Go to the menu Format-->Number-->More Formats-->Custom Number Format...
In the entry area at the top, enter the following: #;-#;""
The "format" of the format string is
(positive value format) ; (negative value format) ; (zero value format)
You can apply colors or commas or anything else. See this link for details
instead of your =COUNTIFS(Orders!$T:$T,$B4) use:
=REGEXREPLACE(""&COUNTIFS(Orders!$T:$T,$B4), "^0$", )
also, to speed up things you should avoid "per row formulae" and use ArrayFormulas

Nested Regexmatch Not Working on Range of Zeros and Ones

I have a sum filter formula and have nested a REGEXMATCH function within it as a condition to filter the range to be summed.
The full formula looks like:
=sum(filter(data,
region1=$AF$4,
industry=$A11,
quarter=AG$9,
REGEXMATCH(consent,"1")))
The range "consent" is just 0 or 1 for each value in the range.
When I run this function 0 is returned whereas I expect about 1,000.
The documentation for REGEXMATCH says
"This function only works with text (not numbers) as input and returns
text as output. If a number is desired as the output, try using the
VALUE function in conjunction with this function. If numbers are used
as input, convert them to text using the TEXT function."
I'm not sure what to do with that. I tried the following:
REGEXMATCH(consent,1) // no luck
REGEXMATCH(TEXT(consent),"1") // no luck
REGEXMATCH(TEXT(consent),TEXT(1)) // no luck
But, if I do this:
REGEXMATCH(consent,".*") // does work for all data in consent
How can I tell GSheets to REGEXMATCH on the range consent where it equals 1?
I think the documentation is a bit misleading, because while you can convert to text using the TEXT function (which requires a second argument that prescribes the format of the output, which is why your attempt was not working), it is probably not the easiest way to do it. Probably better would be TO_TEXT, or simply appending &"":
REGEXMATCH(TO_TEXT(consent),"1")
REGEXMATCH(consent&"","1")
That being said, is there a reason you can't just use consent=1 (in which case, you could just use consent by itself as an argument in FILTER)?

Check if cell contains numbers in Google Spreadsheet using RegExMatch

I want to check if specific cell contain only numbers.
I know I should use RegExMatch but I get an error.
This is what I wrote : =if(RegExMatch(H2,[0-9]),"a","b")
I want it to say : write 'a' if H2 contains only numbers, 'b' otherwise.
Thank you
Try this:
=IF(ISNUMBER(H2,"A","B"))
or
=if(isna(REGEXEXTRACT(text(H2,"#"),"\d+")),"b","a")
One reason your match isn't working also - is that it in interpreting your numbers as text. the is number function is a bit more consistent, but if you really need to use regex, then you can see in the second formula where im making sure the that source text is matching against a string.
Your formula is right, simple you forget the double quotes at regexmatch function's regular_expression .
This is the right formula: =if(RegExMatch(B20,"[0-9]"),"a","b")
=REGEXREPLACE(“text”,”regex”,”replacement”)
It spits out the entire content but with the regular expression matched content replaced. =REGEXREPLACE(A2,[0-9],"a")
=REGEXREPLACE(A2,![0-9],"b")//not sure about not sign.
will fill a cell with the same text as A2, but with the 0-9 becoming an a!