VLOOKUP on computed cell values - google-sheets

I cannot have VLOOKUP to properly work if it has to match computed values.
Please see this example:
In test sheet, row 1 tests data in computed sheet, where B2 cell is the result of =RIGHT(A1, 4).
Value 1234 is not found
Meanwhile, on row 2 of test, if 1234 is the hardcoded value of the cell — sheet hardcoded —
Value is found.
Is this a bug?

Is it enough for you to change your formula to =value(RIGHT(A1,4)) ?
I'd say not a bug (Excel behaves the same way). Use of =RIGHT has automatically output as a string. If instead you had had =1233+1 you should not have had any problem.

Related

GSHEET How do I Extract Text from formula for creating automatic cell reference

The context :
Each time i need a cell reference from my other sheet, I need others cell reference from the same line but from different column.
I would like to automate those adding reference values depending on the first reference i add manually.
I have a sheet named alpha and a sheet named beta
I have a cell A1 in alpha that refers to beta A1
I have this referred cell formula in alpha A1 to have the value from beta A1
=beta!A1
Objectif :
I would like to have in alpha B2 the cell automatically filled-in by the value from beta A7
the equivalence of this refered cell formula
=beta!A7
Because the number seven will never change, only the column can change it could be:
=beta!AC1
so I will need =beta!AC7 automatically populated.
The Goal :
The goal is to extract from the formula in alpha A1 all characters except number(s) by a formula (like SEARCH, LEN, from FORMULATEXT) to obtain
=beta!A
with this result, I will concatenate with a cell that has the value "7". to obtain the formula for the cell reference.
A
B
C
1
=beta!A1
=beta!A7
7
2
=beta!AC1
=beta!AC7
If anyone can give me this formula clue or a better way to reach my goal would be good
I tried the regex below but it removed the punctuation
=REGEXREPLACE(FORMULATEXT(A1),"[^[:alpha:]]", "")&C1 where C1 is the value "7"
But i have all the need without the exclamation mark "!"
=betaA7
instead of
=beta!A7
Thank you
this is what you want
Use this to REGEXEXTRACT all the numbers and REGEXREPLACE then with "" nothing. and add &$C1 the value in C1.
=REGEXREPLACE(A1, REGEXEXTRACT(A1, "[0-9]+"), "")&$C1
A better way
See in Beta!A1 we have a value of Im beta A1
And in Beta!A7 we have a value of Im beta A7
And in alpha!A1 we hane the formula =beta!A1
To get the value of beta!A7 using the formula in alpha!A1 as an input we use this formula in beta!B1
=INDIRECT(REGEXREPLACE(SUBSTITUTE(FORMULATEXT(A1),"=",""), REGEXEXTRACT(SUBSTITUTE(FORMULATEXT(A1),"=",""), "[0-9]+"), "")&$C1)
Explanation
INDIRECT(=beta!A1)
Even more simpler approach
Use this formula directly
=OFFSET(beta!A1,C1-1,0)

if value between 10 & 20 then display 20% of value in another cell

i want to find the percentage of the values in range. for eg : if value between 10 & 20 then display the 20% of value, if value between 20.01 & 50 then display the 10% of value.
a sheet is attached here for more clarification.
https://docs.google.com/spreadsheets/d/1HlIflx8GkoCesl2jWdoHe30PzzAbuXUQE9XGasE7Iys/edit?usp=sharing
I have added three sheets to your sample spreadsheet.
The sheet called "Erik Help - Option 1" is self-contained. See the stand-alone array formula in cell B1:
=ArrayFormula({"UPDATED PRICE"; IF(A2:A="","",IFS(A2:A<=7,9.95, A2:A<=10,11.45, A2:A<=20,A2:A*20%, A2:A<=50,A2:A*10%, A2:A,A2:A*5%))})
This formula creates a virtual array by using curly brackets { }. First, the header is placed. Then a simple IF statement checks for whether there is anything in each cell of Column A. If there is not, then Column B will be null; if there is, then Column B will check the value of each cell in Column A against the elements of the IFS function.
The second sheet, entitled "Erik Help - Option 2," relies on the third sheet, entitled "Values." This would allow you more ease in changing assigned values.
The array formula in cell B1 of "Erik Help - Option 2" is as follows:
=ArrayFormula({"UPDATED PRICE"; IF(A2:A="","",IF(VLOOKUP(A2:A,Values!A2:C,3,TRUE)>=1,VLOOKUP(A2:A,Values!A2:C,3,TRUE),A2:A*VLOOKUP(A2:A,Values!A2:C,3,TRUE)))})
This works the same as the previous formula except that instead of referencing IFS for values, this formula references the sheet "Values" with a LOOKUP.
After checking for null values, another IF statement checks to see if the lookup value from Values!C2:C >=1 (i.e., whether it is a dollar amount or a percentage):
If this is TRUE (i.e., if the corresponding Values!C2:C value a dollar amount), the VLOOKUP runs again, comparing values from 'Erik Help - Option 2!'A2:A with the values in Values!A2:A and returning the value in Values!C2:C.
If this is FALSE (i.e., if the corresponding Values!C2:C value is a percentage amount), the values from 'Erik Help - Option 2'!A2:A are multiplied by the corresponding values in Values!C2:C.
As you can see, the results from "Erik Help - Option 1" and "Erik Help - Option 2" are identical. So it comes down to preference. If you want a self-contained option and feel comfortable editing the formula itself in the future if values change, use Option 1. If you prefer the ease of changing the values in chart form, use Option 2 with the Values chart.
NOTE: In my sheets, I also applied currency formatting (Format > Number > Currency) to all cells that contain or might contain dollar values.

Different Outputs while counting unique values in a Google Sheet

I have a google sheet which looks like this :
The formula for cell M3 is =COUNTA(UNIQUE(B3:L3)) which outputs the 01/10/00. However the cell B18 is =COUNTA(UNIQUE(B3:B17)) and its output is 15
I wanted to get this count of unique values in the range using the formula but can't figure out the cause of difference of the outputs. Also, the count of unique values in a row should be 11 which is not really reflected in M3 and any changes are not changing the value of the output either.
there is a combo formula for that called COUNTUNIQUE
=COUNTUNIQUE(B3:L3)
The formatting of M3 is probably set to Date and that's converting your number into that date view. Additionally, if you're getting a higher number than you expect in general, double check for trailing spaces that can trick the unique() function.

VLOOKUP formula cannot read dataset generated by another formula

I am using Google Sheets and the VLOOKUP formula within it. Why does the following formula return a 0?
Columns C2:Q150 are generated from a formula and number's pulled from other sheets. Columns U4:U18 are generated by using the LARGE function (to find max in a sorted manner)
According to the documentation you posted, Google Sheet's VLOOKUP function works in the same way as Excel's.
So you are looking in the range $C$2:$C$150 (the first column of your table, which you specified as $C$2:$Q$150) to find the last value in that column that is less than or equal to your 36, i.e. the value in cell U4, and then returning the value in the first column of your $C$2:$Q$150 range on the found cell's row.
If the last cell in column C contains a zero, the answer will be 0.
Re the fourth parameter (which you are setting to TRUE), the documentation says in its Notes:
If is_sorted is set to TRUE or omitted, and the first column of the range is not in sorted order, an incorrect value might be returned. If VLOOKUP doesn’t appear to be giving correct results, check that the last argument is set to FALSE. If the data is sorted and you need to optimize for performance, set it to TRUE. In most cases it should be set to FALSE.
For excel try this in V4,
=INDEX(A:A, AGGREGATE(15, 6, ROW($2:$20)/(C$2:Q$20=U4), COUNTIF(U$4:U4, U4)))
Fill down as appropriate.
In google-sheets this translates to,
=index(A:A, small(if(C$2:Q$20=U4, row($2:$20)), countif(U$4:U4, U4)))

Array formula is misbehaving

I want to add an extra column which takes a value with a VLOOKUP from another sheet and adds the value to each cell in that column if the value's ID matches an id from another column in this spreadsheet.
I have partial success with my formula. It is working for almost all the cells/rows, but it won't populate the last 9 cells(out of 3000 rows) with the desired value.
Here is the formula :
=ARRAYFORMULA(VLOOKUP(G3:INDEX(G3:G,COUNT(G3:G)),'Program IDs'!A$1:B$17,2,0))
I don't understand what is wrong in my formula. Also, the data in the problematic rows is perfectly fine and in the same format as in the other rows.
If my formula seems correct, then I'd like to get suggestions for alternatives to that formula, so I can make it work one way or another.
=ARRAYFORMULA(VLOOKUP(G3:INDEX(G3:G,COUNT(G3:G)+9),'Program IDs'!A$1:B$17,2,0))
There are 9 blank rows somewhere in your 3000 rows. I've made the necessary changes.

Resources