IF nested query

Deelof

New Member
Joined
Aug 30, 2023
Messages
34
Office Version
  1. 2019
Platform
  1. Windows
What's the best formula for the below criteria to return specific text as the Action column?

If "On Web" and Stock is less than or equal to 2 and Core or Non Core = "False", "Remove from Web"
And
If "On Web" and Stock is equal to 0 but Core or Non Core = "True", "Leave on Web"
And
If "Not on Web", stock is greater than 2 - "Data Checks"
And ignore any blanks in the Web Status column, returning a blank Action

WEB STATUSCORENON CORESTOCKACTION
ON WEBFALSEFALSE2REMOVE FROM WEB
ON WEBFALSEFALSE5LEAVE ON WEB
ON WEBFALSETRUE0NON CORE - LEAVE ON WEB
ON WEBFALSETRUE1NON CORE - LEAVE ON WEB
ON WEBFALSETRUE0NON CORE - LEAVE ON WEB
ON WEBFALSETRUE0NON CORE - LEAVE ON WEB
ON WEBFALSETRUE0NON CORE - LEAVE ON WEB
ON WEBFALSETRUE0NON CORE - LEAVE ON WEB
ON WEBFALSETRUE0NON CORE - LEAVE ON WEB
ON WEBFALSEFALSE0REMOVE FROM WEB
ON WEBFALSEFALSE10LEAVE ON WEB
NOT ON WEBFALSEFALSE32DATA CHECKS
NOT ON WEBFALSEFALSE20DATA CHECKS
ON WEBTRUEFALSE0LEAVE ON WEB
ON WEBFALSEFALSE6LEAVE ON WEB
ON WEBFALSEFALSE12LEAVE ON WEB
ON WEBFALSEFALSE7LEAVE ON WEB
ON WEBTRUEFALSE1CORE - LEAVE ON WEB
ON WEBTRUEFALSE9CORE - LEAVE ON WEB
ON WEBFALSETRUE0NON CORE - LEAVE ON WEB
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I don't believe any of your rows satisfy the requirement for "Leave on Web", because none of the rows with "ON WEB" in web status has a stock level of 0 and the logic of the first test
and Core or Non Core = "False", "Remove from Web"
already eliminates the next option.
If "On Web" and Stock is equal to 0
Therefore, here's an option with your current logic:
Book1
ABCDE
1WEB STATUSCORENON CORESTOCKACTION
2ON WEBFALSEFALSE2REMOVE FROM WEB
3ON WEBFALSEFALSE5 
4ON WEBFALSETRUE0REMOVE FROM WEB
5ON WEBFALSETRUE1REMOVE FROM WEB
6ON WEBFALSETRUE0REMOVE FROM WEB
7ON WEBFALSETRUE0REMOVE FROM WEB
8ON WEBFALSETRUE0REMOVE FROM WEB
9ON WEBFALSETRUE0REMOVE FROM WEB
10ON WEBFALSETRUE0REMOVE FROM WEB
11ON WEBFALSEFALSE0REMOVE FROM WEB
12ON WEBFALSEFALSE10 
13NOT ON WEBFALSEFALSE32Data Checks
14NOT ON WEBFALSEFALSE20Data Checks
15ON WEBTRUEFALSE0REMOVE FROM WEB
16ON WEBFALSEFALSE6 
17ON WEBFALSEFALSE12 
18ON WEBFALSEFALSE7 
19ON WEBTRUEFALSE1REMOVE FROM WEB
20ON WEBTRUEFALSE9 
21ON WEBFALSETRUE0REMOVE FROM WEB
Sheet1
Cell Formulas
RangeFormula
E2:E21E2=IF(AND(A2="ON WEB",OR(B2=FALSE,C2=FALSE),D2<=2),"REMOVE FROM WEB",IF(AND(A2="ON WEB",OR(B2=TRUE,C2=TRUE),D2=0),"Leave on Web",IF(AND(A2="NOT ON WEB",D2>2),"Data Checks","")))
 
Upvote 0
Thanks but your suggestion is not quite working as column C = TRUE but action results in Remove from Web?

WEB STATUSCORENON CORESTOCKACTION
ON WEBFALSETRUE
0​
REMOVE FROM WEB
 
Upvote 0
Because your original post states that if either column B OR C contains FALSE - then it should be Remove from Web, and in your example column B is FALSE. I think this is going to boil down to which 'set' of conditions/tests takes precedence.
 
Upvote 0
Ah I see. So how should I adapt if either B or C contains a TRUE to not return Action of Remove from Web or if both state FALSE and 0 stock the Remove from Web? Any suggestions
 
Upvote 0
Receip.xlsm
ABCDEF
1WEB STATUSCORENON CORESTOCKACTIONFormula
2ON WEBNONO2REMOVE FROM WEBRemove From Web
3ON WEBNONO5LEAVE ON WEBLeave On Web
4ON WEBNOYes0NON CORE - LEAVE ON WEBNon Core - Leave on Web
5ON WEBNOYes1NON CORE - LEAVE ON WEBNon Core - Leave on Web
6ON WEBNOYes0NON CORE - LEAVE ON WEBNon Core - Leave on Web
7ON WEBNOYes0NON CORE - LEAVE ON WEBNon Core - Leave on Web
8ON WEBNOYes0NON CORE - LEAVE ON WEBNon Core - Leave on Web
9ON WEBNOYes0NON CORE - LEAVE ON WEBNon Core - Leave on Web
10ON WEBNOYes0NON CORE - LEAVE ON WEBNon Core - Leave on Web
11ON WEBNONO0REMOVE FROM WEBRemove From Web
12ON WEBNONO10LEAVE ON WEBLeave On Web
13NOT ON WEBNONO32DATA CHECKSDate Checks
14NOT ON WEBNONO20DATA CHECKSDate Checks
15ON WEBNONO3LEAVE ON WEBLeave On Web
16ON WEBNONO6LEAVE ON WEBLeave On Web
17ON WEBNONO12LEAVE ON WEBLeave On Web
18ON WEBNONO7LEAVE ON WEBLeave On Web
19ON WEBYesNO1CORE - LEAVE ON WEBCore - Leave on Web
20ON WEBYesNO9CORE - LEAVE ON WEBCore - Leave on Web
21ON WEBNOYes0NON CORE - LEAVE ON WEBNon Core - Leave on Web
Sheet20
Cell Formulas
RangeFormula
F2:F21F2=IF(AND(A2="On Web",D2<=2,B2="No",C2="No"),"Remove From Web",IF(AND(A2="On Web",D2>0,B2="No",C2="No"),"Leave On Web",IF(AND(A2="Not On Web",D2>2),"Date Checks",IF(AND(A2="On Web",D2<2,B2="No",C2="Yes"),"Non Core - Leave on Web",IF(AND(A2="On Web",D2>0,B2="Yes",C2="No"),"Core - Leave on Web","")))))
 
Upvote 0
Do columns B and C need to be Yes/No for the formula to work or can they remain as True/False?
Columns B & C have a look up formula in, will this be preventing the above formula to not
work?
 
Upvote 0
Do columns B and C need to be Yes/No for the formula to work or can they remain as True/False?
Columns B & C have a look up formula in, will this be preventing the above formula to not
work?


when i use true and fasle its not working for me so i changed to Yes /No Then it works
 
Upvote 0
I think the formula provided by @Muhammad_Usman works - if you just change the "Yes" and "No" for TRUE and FALSE (without the quotation marks)
logic.xlsx
ABCDE
1WEB STATUSCORENON CORESTOCKACTION
2ON WEBFALSEFALSE2Remove From Web
3ON WEBFALSEFALSE5Leave On Web
4ON WEBFALSETRUE0Non Core - Leave on Web
5ON WEBFALSETRUE1Non Core - Leave on Web
6ON WEBFALSETRUE0Non Core - Leave on Web
7ON WEBFALSETRUE0Non Core - Leave on Web
8ON WEBFALSETRUE0Non Core - Leave on Web
9ON WEBFALSETRUE0Non Core - Leave on Web
10ON WEBFALSETRUE0Non Core - Leave on Web
11ON WEBFALSEFALSE0Remove From Web
12ON WEBFALSEFALSE10Leave On Web
13NOT ON WEBFALSEFALSE32Date Checks
14NOT ON WEBFALSEFALSE20Date Checks
15ON WEBFALSEFALSE3Leave On Web
16ON WEBFALSEFALSE6Leave On Web
17ON WEBFALSEFALSE12Leave On Web
18ON WEBFALSEFALSE7Leave On Web
19ON WEBTRUEFALSE1Core - Leave on Web
20ON WEBTRUEFALSE9Core - Leave on Web
21ON WEBFALSETRUE0Non Core - Leave on Web
Sheet1
Cell Formulas
RangeFormula
E2:E21E2=IF(AND(A2="On Web",D2<=2,B2=FALSE,C2=FALSE),"Remove From Web",IF(AND(A2="On Web",D2>0,B2=FALSE,C2=FALSE),"Leave On Web",IF(AND(A2="Not On Web",D2>2),"Date Checks",IF(AND(A2="On Web",D2<2,B2=FALSE,C2=TRUE),"Non Core - Leave on Web",IF(AND(A2="On Web",D2>0,B2=TRUE,C2=FALSE),"Core - Leave on Web","")))))


If this does what you want, make sure you mark @Muhammad_Usman 's answer (post #6) as the solution as he did all the hard work on the formula.
 
Upvote 0
I understand your request as follows:

  • If at least 1 TRUE, regardless of stock: Core or Noncore
  • else, if stock <= 2: "Remove"
  • else, if "NOT ON WEB", "Check", else, "Leave"
  • In your explanation, there is no case for ("NOT ON WEB" and stock <= 2), so I assume it is "Remove" (stock <= 2).
Book1
ABCDE
1WEB STATUSCORENON CORESTOCK
2ON WEBFALSEFALSE2Remove from Web
3ON WEBFALSEFALSE5Leave on Web
4ON WEBFALSETRUE0Non Core -Leave on Web
5ON WEBFALSETRUE1Non Core -Leave on Web
6ON WEBFALSETRUE0Non Core -Leave on Web
7ON WEBFALSETRUE0Non Core -Leave on Web
8ON WEBFALSETRUE0Non Core -Leave on Web
9ON WEBFALSETRUE0Non Core -Leave on Web
10ON WEBFALSETRUE0Non Core -Leave on Web
11ON WEBFALSEFALSE0Remove from Web
12ON WEBFALSEFALSE10Leave on Web
13NOT ON WEBFALSEFALSE32Date Checks
14NOT ON WEBFALSEFALSE20Date Checks
15ON WEBFALSEFALSE3Leave on Web
16ON WEBFALSEFALSE6Leave on Web
17ON WEBFALSEFALSE12Leave on Web
18ON WEBFALSEFALSE7Leave on Web
19ON WEBTRUEFALSE1Core - Leave on Web
20ON WEBTRUEFALSE9Core - Leave on Web
21ON WEBFALSETRUE0Non Core -Leave on Web
Sheet1
Cell Formulas
RangeFormula
E2:E21E2=IFERROR(CHOOSE(MATCH(TRUE,B2:C2,0),"Core - ","Non Core -") & "Leave on Web",IF(D2<=2,"Remove from Web",IF(LEFT(A2,3)="NOT","Date Checks","Leave on Web")))
 
Upvote 0

Forum statistics

Threads
1,215,773
Messages
6,126,818
Members
449,340
Latest member
hpm23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top