问题
I'm currently just troubleshooting a report spreadsheet I've written. The logic I had written isn't working, so I thought I'd see if I could ask for some help here.
Essentially, I have a list of contracts, a list of products, a list of end and start dates, and various other pieces of information. I need to know if a product of a renewal using this information.
Example Data:
Product Company Number Start of Contract End of contract Contract ID Include in this month's report
Fax 1234 10.09.2013 10.09.2014 1 No
Fax 1234 10.09.2014 10.09.2015 2 No
Box 5678 11.01.2014 30.04.2015 3 No
Box 5678 01.05.2015 11.01.2016 4 Yes
Fax 5678 01.05.2015 01.05.2016 5 Yes
Cup 9876 03.05.2015 03.05.2016 6 Yes
What I want to do is work out using this data whether the file is new to product, new to business, or renewal of an existing file.
The logic behind whether the contract should be included in this month's report is simple - simply check if Start date
is the month requested elsewhere in the report.
In the example given above,
- Contract ID's 1,3 and 6 are new to business
- ID's 2 and 4 are Renewals
- Id 5 is new to product, with existing business with the company
I've worked out the basic way of working out for this month if there is a new to product file, because the company number won't be unique, but the product will. I'd like to make this better though, because if this done as is, it will return as "False" for the first occurrence of where the product has subsequently been renewed.
What I need to do is find a way of checking if there is a previous contract with us that was with the product listed, contracts with completely new clients, and contracts where there IS a previous contract with us that WASN'T with the same product. In essence, I need the logic for the below answers please!
Results:
Contract ID Renewal? New to Product? New to Business?
1 No No Yes
2 Yes No No
3 No No Yes
4 Yes No No
5 No Yes No
6 No No Yes
I've got a few helper columns so far, like "ended in last 12 months", and "number of agreements". but I keep getting turned around when it comes to the logic for the three final results!
回答1:
Renewal - there is an instance of the same product and company with an earlier start date
=COUNTIFS(A$2:A$7,A2,B$2:B$7,B2,D$2:D$7,"<"&D2)>0
New to product - there is no instance of the same product & company with an earlier start date, but there is an instance of another product & same company with an earlier start date
=AND(COUNTIFS(A$2:A$7,A2,B$2:B$7,B2,D$2:D$7,"<"&D2)=0,COUNTIFS(A$2:A$7,"<>"&A2,B$2:B$7,B2,D$2:D$7,"<"&D2)>0)
New to business - there is no instance of the same company with an earlier start date
=COUNTIFS($B$2:$B$7,B2,$D$2:$D$7,"<"&D2)=0
来源:https://stackoverflow.com/questions/30530423/use-an-array-formula-to-check-if-a-similar-contract-ended-in-the-last-12-months