Showing the last value from VLOOKUP - if-statement

Explanation
The way this spreadsheet should work is by checking if the Status value of the last corresponding Data value, is equal to "OK". If it is, then it'll show the corresponding value in ValueIfOK, in Result, if not, ValueIfOK will be blank, so it should show a blank value in Result.
I created this spreadsheet here to show what I meant above. It can be edited by anyone and doesn't need to login.
Code
=IFERROR(ARRAYFORMULA(
IF(
VLOOKUP(A2:A, Sheet2!A2:D, 2, FALSE) = "OK",
VLOOKUP(A2:A, Sheet2!A2:D, 3, TRUE)
)
))

Reverse the values set
=ARRAYFORMULA(IFERROR(
VLOOKUP(
A:A,
SORT(Sheet2!A:C,ROW(Sheet2!A:A),0),3,0),
))
There is the full explanation

try:
=ARRAYFORMULA(IFNA(VLOOKUP(A:A, SORT(Sheet2!A:C, ROW(Sheet2!A:A), 4, 1), 3, 0)))

Related

Django Dict Filter several AND OR Condition

i try to make a filterdict dynamicaly. As Result i get for example such a filterdict:
filterdict {'price_from__lte': Decimal('120000.00'), 'price_till__gte': Decimal('120000.00'), 'wc': True, 'balcony_count_from__lte': 1, 'balcony_count_till__gte': 1}
So i can filter searchcriterialist = Searchcriteria.objects.filter(**filterdict)
But i want from every field a OR Condition where all items with Null are include. So i need a dict like this:
filterdict {('price_from__lte': Decimal('120000.00') OR 'price_from__lte': NULL), ('price_till__gte': Decimal('120000.00') OR 'price_till': 0), ('wc': True OR 'wc': NULL), ('balcony_count_from__lte': 1 OR 'balcony_count_from':0), ('balcony_count_till__gte': 1 OR 'balcony_count_till':0)}
How can i build dynamical i dict with a mixture of OR and AND Contitions?
Regards
i found a solution with Q().
Thanks

Using IF AND to match three criteria

I am trying to use an IF statement to turn a cell Yes if three conditions are met. It's not working for the third condition. Can anyone look at my formula and point me in the right direction? Note: I can't use array formula because there are other rows in the way.
The three conditions are:
The cells in D2:D say User Task
The cells in B2:B match the cells in E2:E of another sheet and either C2:C of that sheet say Yes or Reloaded.
The cells in B2:B of the other sheet match Customer.
=IF(AND(D2:D="User Task",REGEXMATCH(VLOOKUP(B2:B, {
IMPORTRANGE("1YMBUYC6JgQke-2YWs_VZx9zqlmOdhV8WYvhTpTVxBYM", "Sheet1!E2:E"),
IMPORTRANGE("1YMBUYC6JgQke-2YWs_VZx9zqlmOdhV8WYvhTpTVxBYM", "Sheet1!C2:C")}, 2, 0),
"Yes|Reloaded")=TRUE,
IMPORTRANGE("1YMBUYC6JgQke-2YWs_VZx9zqlmOdhV8WYvhTpTVxBYM", "Sheet1!B2:B")="Customer"), "Yes", )
Reference sheets:
Test Sheet 2
Test Sheet 1
it goes like this:
=IF( (con1=true)*(con2=true)*(con3=true), do "yes", otherwise empty)
eg:
=ARRAYFORMULA(IFERROR(IF(($D$2:$D="User Task")*(REGEXMATCH(VLOOKUP($B2:B, {
IMPORTRANGE("1YMBUYC6JgQke-2YWs_VZx9zqlmOdhV8WYvhTpTVxBYM", "Sheet1!E2:E"),
IMPORTRANGE("1YMBUYC6JgQke-2YWs_VZx9zqlmOdhV8WYvhTpTVxBYM", "Sheet1!C2:C")}, 2, 0),
"Yes|Reloaded")=TRUE)*
(IMPORTRANGE("1YMBUYC6JgQke-2YWs_VZx9zqlmOdhV8WYvhTpTVxBYM", "Sheet1!B2:B")="Customer"),
"Yes", )))

How to return a value based on whether two columns contains values present in other columns

I have four columns to compare against and a fifth one which contains the target value. I need to compare the four columns (2 each) and if they match then return the corresponding value in the fifth column. One of the columns requires comparing using the typical = sign while the other column requires checking if the other column contains part of the text. I tried using regexmatch but I couldn't get the formula to return the values as I'd wanted.
Here is the link to the google sheets file:
https://docs.google.com/spreadsheets/d/13RotkFBSOTylN6YOxPjzYDNWwYtCXo6Ewh6UtCi0i1E/edit?usp=sharing
try:
=ARRAYFORMULA(IFNA(VLOOKUP(IFNA(REGEXEXTRACT(A2:A15,
TEXTJOIN("|", 1, SORT(D2:D15, 1, 0))))&"♦"&B2:B15,
{D2:D15&"♦"&E2:E15, F2:F15}, 2, 0)))
try:
=ARRAYFORMULA(IF((D2:D15=IFNA(REGEXEXTRACT(A2:A15,
TEXTJOIN("|", 1, SORT(D2:D15, 1, 0)))))*(B2:B15=E2:E15), F2:F15, ))

Vlookup then return a different row in Google Sheets

I'm struggling to figure out how to get sheets to first look up the location of a key value and then look up which of the sub values it should take. Best would be to include an example, which:
https://docs.google.com/spreadsheets/d/1pL62W7pSImMlTdnU3RMV4VDK3KIuNBT8l3VxClLGTd4/edit?usp=sharing
What I'm hoping to achieve is that the values for item 1, when selected, auto fill in the correct gear builder fields.
Any advice on this is hugely appreciated.
try:
=ARRAYFORMULA(IFNA(VLOOKUP(
IF(F4:F12<>"", VLOOKUP(ROW(A4:A12),
IF(G4:G12<>"", {ROW(A4:A12), G4:G12&"♦"}), 2, 1), )&F4:F12, {
IF(B4:B12<>"", VLOOKUP(ROW(A4:A12),
IF(A4:A12<>"", {ROW(A4:A12), A4:A12&"♦"}), 2, 1), )&B4:B12, C4:C12}, 2, 0)))

If Cell equals value AND another cell is greater then another cell

So right now my formula is
=COUNTIFS(D4,"Ajay", E4,">"&F4)
Which seems to work fine for 1 item but doesn't seem to work as a range?
=COUNTIFS(D4:D50,"Ajay", E4:E50,">"&F4:F50)
Any ideas?
=ARRAYFORMULA(IF((D4:D50="Ajay")*(E4:E50>F4:F50), 1, ))
or the actual count of it:
=SUM(ARRAYFORMULA(IF((D4:D50="Ajay")*(E4:E50>F4:F50), 1, )))