pulling and comparing dates in excel - excel

For example:
On my first tab Last visit, I have columns, Customer Name, Customer # and Scheduled date
On my second tab, All visits I have Customer Name, Customer #, and Visit Dates. Now, this tab shows all of the visit dates (even the last one that is on Last visit) while the first tab just shows their last visit date and their next scheduled date.
Goal: On my first tab, Last Visit, I need some logic that compares the scheduled visit date with all of the visit dates.. for that specific customer ID. So on the next column after Scheduled date I want a new column Last visit date that compares the visit before the last visit date for that specific customer. So some customers have multiple visits, I need each cell for each customer (over 300 for this store) to read all of the times that they visited and only pull the max (most recent BUT NOT the one that is their last visit) date from the second tab All visits
The reason I want the second largest date of all their visits is because in the all visits tab, even their scheduled date is entered in there.
Example: Tab 1:
Billy Joe 12345 1/02/15 <-- Scheduled visit new column --> visit before last visit
Custmer2 Id2 Date
EtcTab 2:
Billy Joe 12345 03/15/14
Billy Joe 12345 04/15/14
Billy Joe 12345 1/02/15
So I would want the date 4/15/14 and not the other two..
I have a partial equation that works for MOST customers.the problem with the equation is:
If a customer visits more than once per month, it still pulls the 2nd highest date of all his/her visits.. how do I make it check to make sure that the visit before the last visit has to be less than their last visit
Here's my equation:
{=LARGE(IF(('All visits'!B:B='Last visit'!B2),('All visits'!C:C)),2)}
B2 corresponds to the customer id (its matching their id on the other page, so when I drag it down it just continues to match the id's)...
An example of an issue:
6/3/2015
6/18/2015
6/26/2015
6/9/2015
Notice how there are multiple visits per month, so my equation will put 6/18/2015 in all of the spots even though their scheduled visits for that month would be less than their last visit.

If I understand this correctly, all we need to do is add an extra array criteria in your LARGE function.
You already are getting the 2nd largest based on the customer ID. But we want the 2nd largest based on the customer Id and based on the scheduled date:
=LARGE(('All visits'!B:B='Last visit'!B1)*('All visits'!C:C>0)*(IF('All visits'!C:C<='Last visit'!C1,'All visits'!C:C)),2)
^^^^^^^^^ Customer ID ^^^^^^^^ ^^ignore blanks^^ ^^^^ Only grab the dates that are <= last visit ^^^^ ^ 2nd largest
Edit to add additional checks for when the customer only has 1 visit date:
If we want it to display #N/A if there is less than two dates we have to use a SUMPRODUCT to get the total amount of entries:
SUMPRODUCT(('All visits'!B:B='Last visit'!B1)*('All visits'!C:C>0)*('All visits'!C:C<='Last visit'!C1))
We can then add that into an IF statement to return either NA() for the <2 case or our original formula for the >=2case:
=IF(SUMPRODUCT(('All visits'!B:B='Last visit'!B1)*('All visits'!C:C>0)*('All visits'!C:C<='Last visit'!C1))<2,NA(),LARGE(('All visits'!B:B='Last visit'!B1)*('All visits'!C:C>0)*(IF('All visits'!C:C<='Last visit'!C1,'All visits'!C:C)),2))
You can change the NA() to whatever fits your requirements

Related

excel formula for date loop and backwords logic

Hi I have a problem developing formula to calculate following logic in Excel. I need to identify patients visits within 30 days interval and then within the identified 30 days interval the most latest date for prescribed medication.
lets say patients first visit was on 18Dec2018, this should count as New visit. so all visits until 18Jan2019 are considired as within 30days visits. This calculation I have solved nicely with this formula.
=OM(OCH(ELLER(C3=C2;C3=C4);ANTAL.OM(C:C;C3)>1;ANTAL.OM(C$2:C3;C3)>1;DAGAR(A3;A2)<30;DAGAR(A3;A4)<30;DAGAR(A:A;A3)<30);"Within 30dgr";"New Visit")
And I get in Kolumn G.
No I however within period 18Dec to 18 Jan need to identify latest date for Recepee Registered Date which is available in Kolumn F and I got stack which formula even to start with trying.
For the first part of your problem, there is a small error in your formula - the last row should not be New Visit since the difference is less than 30.
To keep things understandable, I have created 1 extra column as described below:
Date Difference from latest new entry: this will be
a. 0 if - first entry of patient ;
b. difference between row's date - previous new entry date
c. reset when the difference exceeds 30 - for ex: in row 5 the diff > 30 thus in row 6 it gets reset and the difference is calculated between row6 and row5 instead of row6 and row1
Unique Visit: marks whether the visit is new or within 30 days
Formula for date difference(put in row 1):
=IF(D2<>D1,0,IF(I1="New",B2-B1,B2-B1+H1))
Formula for Unique Visit:
=IF(D2=D1,IF(H2<30,"Within 30","New"),"New")
Put these formulas in first row and drag down to auto-fill.
Latest Recipee Register Date: Captures Recepee register date if the entry is last in entry of 30 days.
Formula:
=IF(D2<>D3,G2,IF(I3="New",G2,""))
Note: I see that your data is sorted with respect to date and other dates are sorted in ascending order as well. These above formulas will work when the data is sorted in ascending order for the all the dates. For other sorting the formulas will need to change.

Cash-flow forecasting in excel

I would like it to be able to input contract details (name of the client, duration of the contract and total yearly amount ). Using these contract details, I would like for the program or template to populate a calendar in which we can see each day's deposits.
For example: If I entered 2 contracts:
Total yearly amount of 120$ that start on 01/01/2019
Total yearly amount of 180$ that start on 01/03/2019
by choosing to view March calendar, I would see on the 01/03/2019 2 deposits one of 10$ and the other of 15$ for a total of 25$. But, If I choose to view the month of February, I would see on 01/02/2019 1 deposit of 10$.
I have started an excel sheet which populates it perfectly if it is one time deposit for a specific date.
Where I got stuck was for monthly deposits and special deposits (special conditions where the first month required 25% of the total yearly amount, and will complete the remainder 75% of the total yearly amount in 5 equal deposit the following months).
Here is my basic formula I have put on each day for the month of Janurary:
=IFERROR(IF(AND(VALUE(LEFT(Inputs!$D3,2))=B$2,(VALUE(MID(Inputs!$D3,4,2))='C.F. JAN'!$B$1)),IF(Inputs!$C3="Fixed Monthly",Inputs!$G3/12,IF(Inputs!$C3="Yearly",Inputs!$G3,"")),""),"")
Here is the one of Februrary:
=IFERROR(IF(AND(VALUE(LEFT(Inputs!$D3,2))=C$2,(VALUE(MID(Inputs!$D3,4,2))='C.F. FEB'!$B$1)),IF(Inputs!$C3="Fixed Monthly",Inputs!$G3/12,IF(Inputs!$C3="Yearly",Inputs!$G3,"")),""),"")
I have created sheets for each month that sum the amounts each client's appropriate deposit.
#jessi here is how my data looks like:
here is the formula on M3:
=SUMIF($D$3:$D$10000,$L3,$H$3:$H$10000)+SUMIFS($I$3:$I$10000,$D$3:$D$10000,"<"&$L3,$J$3:$J$10000,">="&$L3)
So, you can do some preliminary math so that your if statements are very simple.
Here's an example. see the added columns? You could enter the data for Contract, Value, Start, First, and Installments. Calculations for FirstPayment, NormalPayment, and Stop.
FirstPayment, for contract a, Row 2, calculated as:
=IF(ISBLANK(D2),G2,D2*B2)
NormalPayment for contract a, Row 2, calculated as:
=IF(ISBLANK(D2),B2/E2,(1-D2)*B2/E2)
Stop for contract a, Row 2 calculated as:
=IF(ISBLANK(D2),EDATE(C2,E2),EDATE(C2,E2+1))
Then, the months with their payments expected, look like so (the formula for January shown):
NOTE: the date 2019-01-01 is in A7, the result (where this formula goes) is in A8. Copy and paste for rest of columns.
=SUMIF($C$2:$C$4,$A7,$F$2:$F$4)+SUMIFS($G$2:G$4,$C$2:$C$4,"<"&$A7,$H$2:$H$4,">="&$A7)
Note that the first SUMIF is dealing with anything that is in its first month. The SUMIFs is dealing with anything that is between Start and Stop.
Edit for changed question to show cashflow by day
To show by day, you first need to add another column, let's say column I, to the data table for contracts. This is the DAY column. DAY($C2). To keep things simple for your cashflow, actually make this If(day($C2)>28),1,day($C2)) to make any falls on 29, 30, or 31 to show up on the next first. You can make other choices here.
Then, you can have each day in time in your cashflow sheet.
I put the cashflow on a new tab and named the contracts data tab CONTRACTS
The cashflow formula (with date in $A2 and result in $B2) is:
=SUMIF(CONTRACTS!$C$2:$C$5,$A2,CONTRACTS!$F$2:$F$5)+SUMIFS(CONTRACTS!$G$2:G$5,CONTRACTS!$C$2:$C$5,"<"&$A2,CONTRACTS!$H$2:$H$5,">="&$A2,CONTRACTS!$I$2:$I$5,DAY(A2))

Excel countif integer but exclude date value

I have a basic Excel file to log healthcare survey completed each week, identified by its Project ID, city, type of facility, date completed, and person assigned.
For the week of 10/02/17, I just want to count the number of projects completed that starts in the 17000s; ignore projects in the 1000s.
For example, week of 10/02/17, North zone, =COUNTIF(H3:L9,">17000") = 11. My expected result is 4 not 11 as I want to exclude the date values from the count. See image screenshot for clarification. Thanks
=COUNTIF(H3:L9,">17000")
simply edit your countif statement to exclude the rest of the cells.
=COUNTIF(H3:H9, ">17000")

NetSuite search to list customers not trading in last 12 months

I'm looking to provide a list of Customers in NetSuite who have NOT traded in the last 12 months (fiscal year) using the saved search functionality.
in the saved search criteria add the following entries
Date of last sales - is not empty
Date of last order - is not empty
you can also add another criteria for Transactions Field : Date and specify the timeline.
it will give you a list of active customer with orders/sales for your specified time period.
I hope this works for you.

Excel Formula for Counting 1st and 2nd Occurrence

Out of 4 weeks, I can visit or not visit a store, and on each visit I can or cannot conduct an activity.
How can I use a formula to count whether an activity was conducted on my first and second visits?- There could be as many as 4 visits or as few as zero visits, but I only want to look at the first and second visit, and if there was an activity performed during those specific visists.
My example data is arranged in 9 Columns; Row 1 is the store number, Row 2 tells me if a i visited the store in week 1 and Row 3 tells me if I conducted an activity on my visit in Week 1, repeats for each week and all data is 1s and 0s. The result i need is three rows; representing each possible visit and the count of activities in that visit by store number.
I can use multiple IF statements to determine what happened in the first visit, but I am stuck on the second visit.
[IMG]http://i.imgur.com/pOWqxg3.png[/IMG] - I have updated the image - Should have been activities per visit and I have also changed the word Call to Visit.
You can do this with a sum product. Move the columns so all the Visits are adjacent to each other and all the Activities are adjacent to each other so you can click and drag them as arrays.
Then do a sumproduct to multiply the Visit array by the Activity array. If the sumproduct for a row = 2, then the user performed the activity in both the weeks he visited.
=SUMPRODUCT(B2:E2,F2:I2)
Screenshot with formula and example table below
https://www.dropbox.com/s/8guruiv8ct2eheu/Screen%20Shot%202014-12-02%20at%201.22.40%20PM.png?dl=0

Resources