If Statement- Multiple Conditions

pto160

Active Member
Joined
Feb 1, 2009
Messages
477
Office Version
  1. 365
Platform
  1. Windows
I am trying to write an If statement for multiple conditions that is a bit tricky. I am trying to write a condition in column E that says Yes or No. I want to include this in a pivot table report. The condition is when the type is equal to credit and the date is equal to or greater than 2/1/22 then I want a yes in column E, but to also include the original type= sale that could have occurred before 2/1/22.
So in this case for example for invoice 100, there is a credit that occurred at 2/5/22, but there is a SALE that occurred on 12/13/21 so both would be yes. Here is what I am looking for.

Book1
ABCDE
1What I want
2DateTypeInvoice #AmountInclude
312/13/2021Sale10015Yes
41/15/2022Credit20030No
52/5/2022Credit10010Yes
61/1/2022Sale20050No
72/10/2022Sale30060Yes
82/16/2022Credit30020Yes
Sheet2
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try below . I am confused with orange highlighted invoice i think you wrote the answer incorrect.

Also note that The date format on my PC is : DD-MM-YYY and you are using MM-DD-YYY . Please Make changes accordingly.


Book1
ABCDEF
1What I want
2DateTypeInvoice #AmountInclude
313-Dec-21Sale10015YesYes
415-Jan-22Credit20030NoNo
55-Feb-22Credit10010YesYes
61-Jan-22Sale20050NoYes
710-Feb-22Sale30060YesYes
816-Feb-22Credit30020YesYes
Sheet1
Cell Formulas
RangeFormula
F3:F8F3=IF(AND(B3="Credit",A3>("1-2-2022")*1),"Yes",IF(AND(B3="Sale",A3<("2-1-2022")*1),"Yes",IF(AND(B3="Sale",A3>("2-1-2022")*1),"Yes","No")))
 
Upvote 0
pto because you can never have too many solutions, here is mine. Now like earth I have to wonder about Cells E6 but also E7. So let the discission begin.



22-03-02 if.xlsx
ABCDEFG
1What I want
2DateTypeInvoice #AmountInclude
312/13/2021Sale10015YesYes
41/15/2022Credit20030NoNo
52/5/2022Credit10010YesYes
61/1/2022Sale20050YesNo
72/10/2022Sale30060NoYes
82/16/2022Credit30020YesYes
Data
Cell Formulas
RangeFormula
E3:E8E3=IF(OR(AND(A3>=44593,B3="Credit"),AND(A3<=44593,B3="Sale")),"Yes","No")
 
Upvote 0
Thanks for responding.
For the response to earthworm, the credit for invoice 200 is Jan 15 2022, which is before Feb 1 2022, so the credit and sale will be "No".
For the response to Ezguy4u , the credit for invoice 300 occurred equal to or greater than February 1, 2022, so the credit and sale is yes.
To summarize, if the credit is equal or greater than 2/1/22, it is a Yes and the sale is also a Yes, no matter when that SALE occurs.
 
Upvote 0
Hi,

This should do what you want:

Book3.xlsx
ABCDE
1What you want
2DateTypeInvoice #AmountInclude
312/13/2021Sale10015Yes
41/15/2022Credit20030No
52/5/2022Credit10010Yes
61/1/2022Sale20050No
72/10/2022Sale30060Yes
82/16/2022Credit30020Yes
Sheet1031
Cell Formulas
RangeFormula
E3:E8E3=IF(COUNTIFS(A$3:A$8,">=2/1/22",B$3:B$8,"Credit",C$3:C$8,C3),"Yes","No")
 
Upvote 0
Thanks jtakw. It works fantastic. (y) This will really help me with this report at work.
I was trying to combine this formula you provided me with another IF statement, where the invoice has to have both a sale and credit as well.
There are some invoices that have just a credit since I am running this report on a date range and the sale could have occurred before that date range.
E10 will be a NO since there is no SALE.
Book1
ABCDE
1What you want
2DateTypeInvoice #AmountInclude
312/13/2021Sale10015Yes
41/15/2022Credit20030No
52/5/2022Credit10010Yes
61/1/2022Sale20050No
72/10/2022Sale30060Yes
82/16/2022Credit30020Yes
92/15/2022Sale40050No
102/16/2022Credit500100Yes
Sheet1
Cell Formulas
RangeFormula
E3:E10E3=IF(COUNTIFS(A$3:A$10,">=2/1/22",B$3:B$10,"Credit",C$3:C$10,C3),"Yes","No")
 
Upvote 0
Hi,

Try this modified version for your new requirement:

Book3.xlsx
ABCDE
1What you want
2DateTypeInvoice #AmountInclude
312/13/2021Sale10015Yes
41/15/2022Credit20030No
52/5/2022Credit10010Yes
61/1/2022Sale20050No
72/10/2022Sale30060Yes
82/16/2022Credit30020Yes
92/15/2022Sale40050No
102/16/2022Credit500100No
Sheet1031
Cell Formulas
RangeFormula
E3:E10E3=IF(AND(COUNTIFS(B$3:B$10,"Sale",C$3:C$10,C3),COUNTIFS(A$3:A$10,">=2/1/22",B$3:B$10,"Credit",C$3:C$10,C3)),"Yes","No")
 
Upvote 0
Solution
This formula works great.:)?
Thanks so much for your help. This will save me a lot of time.
 
Upvote 0
You're welcome, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

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