IF Statement

jarett

Board Regular
Joined
Apr 12, 2021
Messages
165
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am trying to have two logical test in my IF statement and running into a mind block. I've got the first thought process working where if two columns are <= give result, but I also want to check another column D if it is > column F produce blank value. So in my example on line 360 the value in column H OrderQty should be blank because column D is greater than column F even though my first statement is true. The other cells that produced results in OrderQty are correct.

Reorder_pts.xlsx
ABCDEFGH
1ItemCodeQuantityOnHandQuantityOnSalesOrderQuantityOnPurchaseOrderReorderPointQtyMinimumOrderQtyLastPhysicalCountDateOrderQty
325CVFRD7GY-2XL REG1011262024####################### 
326CVFRD7GY-2XL TAL97121212####################### 
327CVFRD7GY-3XL REG19801212####################### 
328CVFRD7GY-3XL TAL155121212####################### 
329CVFRD7GY-4XL REG2010612####################### 
330CVFRD7GY-4XL TAL2220612####################### 
331CVFRD7GY-5XL REG071366####################### 
332CVFRD7KH-MED REG101121212#######################12
333CVFRD7KH-MED TAL1300612####################### 
334CVFRD7KH-SM REG140036####################### 
335CVFRD7KH-XL REG91012127/7/202312
336CVFRD7KH-XL TAL3800612####################### 
337CVFRD7NY-2XL REG24402024####################### 
338CVFRD7NY-2XL TAL17201212####################### 
339CVFRD7NY-3XL REG15301212####################### 
340CVFRD7NY-3XL TAL21001212####################### 
341CVFRD7NY-4XL REG2200612####################### 
342CVFRD7NY-4XL TAL3100612####################### 
343CVFRD7NY-5XL REG150066####################### 
344CVFRD7NY-LAR REG67262024#######################24
TEST_REORDER
Cell Formulas
RangeFormula
H325:H344H325=IF([@QuantityOnSalesOrder]+[@QuantityOnHand]<= [@ReorderPointQty],[@MinimumOrderQty],IF([@QuantityOnPurchaseOrder]>=[@MinimumOrderQty],"",""))
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Please provide a copy of the data in Row 360 (the one that is causing the problem).

The is definitely an error in your IF statement (the second IF clause, is returning nothing in both the True and False case.

Your current Function for Col H is

=IF([@QuantityOnSalesOrder]+[@QuantityOnHand]<= [@ReorderPointQty],[@MinimumOrderQty],IF([@QuantityOnPurchaseOrder]>=[@MinimumOrderQty],"",""))

If the above logic is valid, I think you could do the following:
A few questions ...
1) is the Sales Order quantity items that are targeted to leave, i.e. they have been sold? If so, shouldn't this quantity be subtracted from the Qty on Hand?

Anyway, again using your existing IF ...
=IF([@QuantityOnSalesOrder]+[@QuantityOnHand]<= [@ReorderPointQty],[@MinimumOrderQty],IF([@QuantityOnPurchaseOrder]>=[@MinimumOrderQty],"",[@MinimumOrderQty]))


But, if this logic is correct would the following logic provide a correct result?
Logic: If QtyOnHand + QtySalesOrder + QtyPurchaseOrder >= QtyReorderPoint Then MinOrderQty Else nothing ("")

=IF([@QuantityOnSalesOrder]+[@QuantityOnHand] + [@QuantityOnPurchaseOrder] <= [@ReorderPointQty],[@MinimumOrderQty], "")
 
Upvote 0
Please provide a copy of the data in Row 360 (the one that is causing the problem).

The is definitely an error in your IF statement (the second IF clause, is returning nothing in both the True and False case.

Your current Function for Col H is

=IF([@QuantityOnSalesOrder]+[@QuantityOnHand]<= [@ReorderPointQty],[@MinimumOrderQty],IF([@QuantityOnPurchaseOrder]>=[@MinimumOrderQty],"",""))

If the above logic is valid, I think you could do the following:
A few questions ...
1) is the Sales Order quantity items that are targeted to leave, i.e. they have been sold? If so, shouldn't this quantity be subtracted from the Qty on Hand?

Anyway, again using your existing IF ...
=IF([@QuantityOnSalesOrder]+[@QuantityOnHand]<= [@ReorderPointQty],[@MinimumOrderQty],IF([@QuantityOnPurchaseOrder]>=[@MinimumOrderQty],"",[@MinimumOrderQty]))


But, if this logic is correct would the following logic provide a correct result?
Logic: If QtyOnHand + QtySalesOrder + QtyPurchaseOrder >= QtyReorderPoint Then MinOrderQty Else nothing ("")

=IF([@QuantityOnSalesOrder]+[@QuantityOnHand] + [@QuantityOnPurchaseOrder] <= [@ReorderPointQty],[@MinimumOrderQty], "")
Sorry I had filtered after I typed the question, I did try the last formula you suggested and it returned all "TRUE" values. The qty on SO are sold but they are not taken out of the on hand yet, so I think my thought process/formula is wrong there, it should be =IF([@QuantityOnHand]-[@QuantityOnSalesOrder]<= [@ReorderPointQty],[@MinimumOrderQty],"") and line 360 is as follows
Reorder_pts.xlsx
ABCDEFGH
360CVFRD7NY-LAR REG68272024#######################24
361CVFRD7NY-LAR TAL39001212####################### 
362CVFRD7NY-MED REG413201212####################### 
363CVFRD7NY-MED TAL3000612####################### 
364CVFRD7NY-SM REG1000612####################### 
365CVFRD7NY-XL REG511182024####################### 
366CVFRD7NY-XL TAL25161212####################### 
367FRT-HJE GRY 2XL52171036366/1/202336
TEST_REORDER
Cell Formulas
RangeFormula
H360:H367H360=IF([@QuantityOnHand]-[@QuantityOnSalesOrder]<= [@ReorderPointQty],[@MinimumOrderQty],"")

where column H should still be blank, but line 367 is correct now
 
Upvote 0
So does it work if we change the formula to:
=IF([@QuantityOnHand] - [@QuantityOnSalesOrder] + [@QuantityOnPurchaseOrder] <= [@ReorderPointQty],[@MinimumOrderQty], "")

IF QtyOnHand - QtySold + QtyOrdered <= QtyReorderPoint Then Show QtyMinimumOrder; Else Nothing ("")

Right?
 
Upvote 0
So does it work if we change the formula to:
=IF([@QuantityOnHand] - [@QuantityOnSalesOrder] + [@QuantityOnPurchaseOrder] <= [@ReorderPointQty],[@MinimumOrderQty], "")

IF QtyOnHand - QtySold + QtyOrdered <= QtyReorderPoint Then Show QtyMinimumOrder; Else Nothing ("")

Right?
No, I do not want to take into account the qty on PO unless the qty on PO is greater than the minorderqty, reasoning is because we might order 1 or 2 pieces if we run out of stock for individual orders, so those items would already be so say "allocated". Only if the qty on PO is larger than the minorderqty would I know if we have inventory coming in for "stock".
 
Upvote 0
Is the =IF equation working correctly?

If not please provide sample data that does not give the correct result.
 
Upvote 0
Why do you expect cell H360 to be blank?
You have 6 on hand, 8 on sales order; that is -2 in your IF function
Which is less than your RE-order quantity threshold.

So, I would expect to see 24 (order amount) in H360.

But, if we include the qty ordered it, would be blank.
 
Upvote 0
Why do you expect cell H360 to be blank?
You have 6 on hand, 8 on sales order; that is -2 in your IF function
Which is less than your RE-order quantity threshold.

So, I would expect to see 24 (order amount) in H360.

But, if we include the qty ordered it, would be blank.
Yes because the qty on PO is larger than the minorderqty so that is why it should be blank, we have already placed an order for 24 so I do not want to prompt to order another 24. The sample data with the 24 on line 360 above shows the wrong result.
 
Upvote 0
No, I do not want to take into account the qty on PO unless the qty on PO is greater than the minorderqty, reasoning is because we might order 1 or 2 pieces if we run out of stock for individual orders, so those items would already be so say "allocated". Only if the qty on PO is larger than the minorderqty would I know if we have inventory coming in for "stock".
 
Upvote 0
OK - I think I have it. You need to check the QtyOrdered>QtyOrderMin first, then test what is OnHand,QtySold see formula below. Please test and let me know.

GetLastRow.xlsm
ABCDEFGH
12CVFRD7GY-4XL TAL2220612####################### 
13CVFRD7GY-5XL REG071366####################### 
14CVFRD7KH-MED REG101121212#######################12
15CVFRD7KH-MED TAL1300612####################### 
16CVFRD7KH-SM REG140036####################### 
17CVFRD7KH-XL REG91012127/7/202312
18CVFRD7KH-XL TAL3800612####################### 
19CVFRD7NY-2XL REG24402024####################### 
20CVFRD7NY-2XL TAL17201212####################### 
21CVFRD7NY-3XL REG15301212####################### 
22CVFRD7NY-3XL TAL21001212####################### 
23CVFRD7NY-4XL REG2200612####################### 
24CVFRD7NY-4XL TAL3100612####################### 
25CVFRD7NY-5XL REG150066####################### 
26CVFRD7NY-LAR REG67262024####################### 
Sheet3
Cell Formulas
RangeFormula
H12:H26H12=IF([@QuantityOnPurchaseOrder]>[@MinimumOrderQty],"",IF([@QuantityOnSalesOrder]+[@QuantityOnHand] <= [@ReorderPointQty],[@MinimumOrderQty], ""))
 
Upvote 0

Forum statistics

Threads
1,215,475
Messages
6,125,028
Members
449,205
Latest member
Eggy66

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