IF statement with Vlookup based on condition - google-sheets

I am currently refining my Google sheet for orders our company receives, but would like some help in creating a condition to an VLOOKUP formula.
To keep the sheet clean, text only appears on input of L column.
We have a second sheet with a simple costing.
This is the formula;
=IF(CONCATENATE(L371)="","",VLOOKUP(L371,COSTING!F:G,2,false))
However, this works for only one supplier at the moment.
Is there a way of adding a condition to take into account a second cell on the main sheet?
Example;
Adding this into the VLOOKUP ...
If X371 = 'SUPPLIER NAME1' look here (L371,COSTING!F:G,2,false), If X371 = 'SUPPLIER NAME2' look here (L371,COSTING!M:N,2,false)
Still learning formulas, so haven't quite mastered how to combine statements.
Any suggestions?

Try
=IF(L371="","",if(X371="SUPPLIER NAME1",vlookup(L371,COSTING!F:G,2,false),If(X371="SUPPLIER NAME2",VLOOKUP(L371,COSTING!F:G,2,false))))

Related

Potentially complicated formula with FILTER, VLOOKUP and multiple sheets

I am looking at using a filter to pull data from one Google sheet automatically to another Google Sheet.
The problem is, some of the values in the cells contain "," which mismatch my vlookups.
I have figured out the formula I need to automatically filter this, but I can't wrap my head around how to insert it with a filter formula.
EDIT: The below formulas are on a separate sheet to Data1 & Data2 called "Filter Sheet"
Here are the two formulas I'd like to combine:
=filter('Data2'!C2:C,'Data2'!A2:A="uk")
This one cleans up the values with "," in them:
if(REGEXMATCH(A8,","),iferror(VLOOKUP(index(split(A8,",",1),1,1),'Data1'!A2:A,1,0),iferror(VLOOKUP(index(split(A8,",",1),1,2),'Data1'!A2:A,1,0),false)))
**EDIT:The formula above looks to a different sheet (Data1) to see if the "split" result matches the VLOOKUP on the current sheet. If it does not then it goes through a loop to finally find a match on Data1 Sheet.
Essentially, I want the second statement to**
How do I insert this "clean up formula" so it can work with the filter formula values?
EDIT: How can I combine the filter formula with the "if(regex etc. formula" based on the conditions set?
OR is there an easier way of doing this?
If this helps with an easier method:
The reason why I use a filter formula is because not everything in Data Sheet 1 is found in Data Sheet 2, so this smooths that process out.
Your help is greatly appreciated and thank you in advanced.
Try this formula directly
=filter(Data2!C2:C,REGEXEXTRACT(Data2!A2:A, " (uk)")="uk")

Google Sheets Array Formula Match on Multiple Conditions, 1 being date that is less than or equal to

I am hoping someone can help me out.
I have 2 different datasets and I am hoping to replicate something like the maxifs function using an arrayformula so that I only need 1 formula and do not need to drag it down.
What I would like to do is return a value that matches a name, and the date is less than or equal to a date in the column. Basically the most recent value that matches those criteria.
I have added a picture below
DEMO FIXED
The maxifs formula I am trying to replicate in this case is: =maxifs(I:I, A:A, G:G, H:H, "<=" & B:B)
Sample Sheet: https://docs.google.com/spreadsheets/d/1mMMT1JbBMTAM0togUFQtctpY5FKzgVaP2_YKnALoHAE/edit?usp=sharing
Thank you in advance.
UPDATE:
I have this formula
=arrayformula(if(len(A2:A), vlookup(A2:A&B2:B, {H2:H&I2:I, J2:J}, 2, false),))
Which almost does what I want, however if there is no date matching i need the value from the next most recent date. Instead this returns an error.
Your new goal has nothing to do with your post. Your image values don't match your sheet, and you don't want a max or equivalent to MAXIFS at all now. So the entire post will be confusing to other contributors and future site visitors. Consider spending adequate time to rework your post question, image and spreadsheet to accurately reflect your new goal in a unified way.
That said, I've added a new sheet ("Erik Help") with a formula highlighted in green which accomplished your new goal as I understand it:
=ArrayFormula(IF(A2:A="",,VLOOKUP(A2:A&"~"&B2:B,SORT({G2:G&"~"&H2:H,I2:I},1,1),2,TRUE)))
ADDENDUM (based on additional comment from OP):
I've modified the formula as follows:
=ArrayFormula(IF(A2:A="",,IFERROR(IF(REGEXEXTRACT(VLOOKUP(A2:A&"~"&B2:B,SORT(G2:G&"~"&H2:H),1,TRUE),"(.+)~")<>A2:A,"no match",VLOOKUP(A2:A&"~"&B2:B,SORT({G2:G&"~"&H2:H,I2:I},1,1),2,TRUE)))))

Google sheets, two-sheet dependent conditional formatting

My problem is probably trivial ... However, I was looking for similar problems and their solutions either do not work for me or I can not apply them.
I have 2 sheets - SheetA and SheetB. They are identical. I want to select every cell in SheetA that is no longer identical to Sheet B.
I was able to use (found here on Stack Overflow) such a function in conditional formatting:
= A1 <> INDIRECT ("SheetB! A" & ROW ())
It works if the range is column A. I know that I can apply this function to each column separately, but there is certainly a way that I can apply the same formula to the whole worksheet.
Will there be anyone who can show me the correct formula?
Edit: I tried to use above formula to every column... And my file become to work very slow... So whoever wants to do the same... think again.
After some tries I decided to move everything from SheetB to SheetA. I paste it a 1000 rows under data of Sheet A. Works fine without "indirect" function. No slow downs. It is not a perfect solution but it works.
But even after my problem is solved different way, I would like to know what is the correct formula for my problem... it might be useful for the future with smaller amount of data.
Solved ;)
You should be able to use the Address function to get the address of the current cell from its row and column:
=A1<>indirect("sheetB!"&address(row(),column()))
or for case-sensitive match:
=not(exact(A1,indirect("sheetB!"&address(row(),column()))))

COUNTIF Formula moves down when row at top added

I have the following COUNTIF Formula in my Google Sheet.
=COUNTIFS('Events/Incidents'!$E$3:$E,X4,'Events/Incidents'!$I$3:$I,"Accident")
This is a sample of the sheet which has the formula in the first row under the "Accidents" header:
It works until a user adds a row 3 to the top of the source sheet (Events/Incidents) then the formula changes to the following so that it captures row 4 down instead of the desired row 3.
=COUNTIFS('Events/Incidents'!$E$4:$E,X4,'Events/Incidents'!$I$4:$I,"Accident")
I used the Query function for "All Events" (the first 3 columns). The Countif formula is under each of the Incidents. In my Countif example, X4 is the Employee, John White which was returned in the QUERY.
The QUERY continues to return/include row 3 but I don't know how to do this for the individual Incidents. I tried adding ArrayFormula to the Countif function but I have the same problem.
Would appreciate some help with this.
I understand that you want to update your QUERY to reflect the correct row without resorting to returning the Branch in every response. If my comprehension is correct, there is a way to reach your goals with little modification.
First, you'll have to create a named range that includes the whole table (from the headers to the last row). You can then use this named range in every formula so new rows can be detected without changing the formula per se.
Finally, you can modify your QUERY to return only the values of Incidents in a Branch with something similar to =QUERY(myNamedRange,"SELECT G WHERE A = 'Auckland'"). That QUERY won't return the Branch, only the Incidents. If you keep having any doubts, please ask me for further help.
I worked it out by combining Countifs with ImportRange:
=COUNTIFS(IMPORTRANGE("1-f6OU8ylDSlpqdpt4P5B7GDcIel3IboVkUbY2huMA6U","Events/Incidents!$E$3:$E"),X4,IMPORTRANGE("1-f6OU8ylDSlpqdpt4P5B7GDcIel3IboVkUbY2huMA6U","Events/Incidents!$I$3:$I"),"Accident")

Highlight rows with unique values when compared to a different sheet

I have two sheets:
The first is the Master Sheet of responses to a survey.
The second will be an Update Sheet auto-generated from the new responses.
New responses can be either entirely new rows or edits/updates to previous entries.
I am trying to create a Conditional Formatting rule to auto-highlight any rows in the Update Sheet which do not match the corresponding rows in the Master sheet.
(A row "does not match" when it shares the same Respondent ID number as the Master sheet row but contains different information in the following cells.)
I'm also trying to make it ignore any empty cells.
I created named ranges: "Master" and "Update" on each sheet respectively.
Here's an image of what I'm trying to accomplish:
I'd like to accomplish this without scripts or using a helper column if possible.
Any help from you genuine experts out there would be greatly appreciated!
And here's the Demo Sheet for reference.
So far I have tried to use INDIRECT to accomplish the cross-sheet highlighting (below). However, that didn't work so I'm obviously doing something wrong.
CONDITIONAL FORMATTING:
- Apply to Range: A3:A200,F5:F200
- Custom Formula: =ISNA(match(A3,INDIRECT("Master!F5:AS"),0))
Update #2:
With help from #I'-'I I've been able to get closer with:
CONDITIONAL FORMATTING:
Apply to range: A3:F200
Custom Formula: =and(isna(match($A3,INDIRECT("Master!F5:F"),0)),not(isblank($a3)))
However, while it now highlights the "New Data" rows, it ignores the "Updated Data" row which has the same Respondent ID but different data in the following cells.
Any suggestions on how to rectify this would be appreciated!
Conditional formatting custom formula applied to range A3:F200:
=IF(LEN($A3),IFERROR(SUMPRODUCT(QUERY(INDIRECT("Master!F5:J"),"where F = "&$A3&" limit 1")<>$A3:$E3),1),)
HTH
Adam
With help from #I'-'I I now have the following solution, which works perfectly. :
=AND(NOT(ISBLANK($A3)),OR(IFERROR(ARRAYFORMULA(VLOOKUP($A3,INDIRECT("MASTER!F5:J"),COLUMN($A$1:$E$1),0)<>$A3:$E3),1)))
#I'-'I provided this explanation:
VLOOKUP to lookup ID(A3) in the master sheet and return the
corresponding 5 columns(5 cells).
VLOOKUP results are compared
against current row's 5 columns(<>A3:E3).
IFERROR to return TRUE if
lookup fails(suggesting NewData).
ISBLANK to ignore blank rows.
AND/OR/NOT Self explanatory. Used to combine TRUE/FALSE in a specific
way to achieve intended result.
The solution by #AdamL also works, but I don't know how to give credit to two answers at the same time.

Resources