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
Related
I have a list of employee names on one tab and another tab with orders shipped by employees and the month they were shipped going back 12 months. I'd like to calculate the average number of products shipped per employee per month, but I need to know how many months they were here to do that. So what I'd like to do is essentially write a formula that says give me the count of the distinct number of months they've been shipping products.
Sample employee data:
And here's the sample data on the individual shipments:
So in short, I need to know that Joe Smith shipped those 250 products across 3 distinct months to see he averages 83.3 shipments per month. Again, because there are many new people who have come onboard in the last 12 months, I can't just divide them all by 12 and need to know how many months they were shipping items in.
FILTER Shipper and Month based on Shipper column with criteria Employee name. Apply UNIQUE on filtered array to get only unique values (name + month number). Use COUNT to get active months. Divide Products Shipped by it.
Result:
Average by Count of Uniques
=LET(Shippers,B2:B11,Months,C2:C11,uShippers,E2:E4,uProducts,F2:F4,
uMonths,BYROW(uShippers,LAMBDA(uShipper,
ROWS(UNIQUE(FILTER(Months,Shippers=uShipper))))),
IFERROR(uProducts/uMonths,""))
You can use this array version, which spills all the results at once:
=LET(empl, A2:A4, prods, B2:B4, shipper, B7:B16, months, C7:C16,
ux, MAP(empl, LAMBDA(e, COUNT(UNIQUE(FILTER(months, shipper=e))))), prods/ux)
Here is the output:
It is also possible not using MAP but it is a verbose solution:
=LET(empl, A2:A4, prods, B2:B4, shipper, B7:B16, months, C7:C16,
left, TRANSPOSE(N(shipper=TOROW(empl))), right, N(months=TOROW(UNIQUE(months))),
cnts, N(MMULT(left, right)>0), ux, MMULT(cnts, SEQUENCE(ROWS(cnts),,1,0)), prods/ux)
Replacing TOROW with TRANSPOSE it should work for older Excel versions.
This is how I would have done it, create a Pivot table(Insert->Pivot Table) with Months as column, Employee as row and the values as count of shipments. Once you have the Pivot table, your life becomes easier. Now you do a count of the employee row (COUNT(COL-1:COL-X)) to count the total months a particular employee showed up.You now have count of shipments and a count of months. You can calculate the average. Not sure I can think of anything else easier.
I have two custom lists in my SharePoint as per the below image. The first list is dynamic, meaning that new items may be added every day. The second list will be static, meaning that i will have a column for each week of the year and as items I will have 6-7 users. No more items will be added to this list.
I need to find a way to fill in the cell F4 with the total charge for User1 in W1 and so on for all the other users and weeks. So in this case, the cell F4 should lookup in the list1, take all the lines where the user is User1 and the week is W1 and sum the charge, so the result should be 3.
Ideally, the result should be a percentage where 1 = 20% and 5 = 100%.
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.
I have a large excel table (25000 rows, 60 columns) with rows for each medical visit for 2000+ patients and then columns for type of visit, procedures, etc.
Each row has the illness ID [DxID], patient ID [ID], and the date of visit [DxDate].
Some patients have multiple rows/visits for the same illness. I need to count the number of illnesses in the cohort and by patient.
I have been able to identify visits on the same day by concatenating [ID] and [DxDate] and then using conditional formatting to find duplicates. I can then walk through those duplicates manually. However, I can't think of a formula that will identify rows with the same ID that occur within 30 days of each other (besides manually reading through all the rows of data).
I am happy to move the data into another database (access, R), but am still faced with the same problem.
Consider a spreadsheet with the following columns:
A || B || C || D || E
PatientID || IllnessID || Date of Visit || PatientIllness || GroupID
(Your existing spreadsheet has columns A, B, and C; D and E are being added to get to the solution to your question.)
Row 1 is just column titles.
For PatientIllness, enter the following formula in cell D2:
=CONCATENATE(A2,B2)
Then fill this all the way down the column.
Sort by PatientIllness ascending, Date of Visit ascending
In cell A2, type 1 (this is the first GroupID).
In cell A3, enter the following formula:
=IF(AND(D3=D2, DAYS(C3,C2) <31),E2,E2+1)
Then fill this all the way down the column.
Now rows with a matching GroupID are for patient/illness combinations that occurred within 30 days of each other (caveats below).
This won't work if you re-sort the data after creating the GroupIDs (because they will recalculate, and that will be wrong). If you need to sort the data after calculating GroupID, I'd suggest copying Column E, then pasting As Values (so you lose the formula, but you can resort and retain the correct GroupIDs).
This approach assumes that groups are open-ended. So a GroupID is not just visit 1 and visit 2 that's within 30 days - if you have visit 1 on 1/1, visit 2 on 1/5, and visit 3 on 2/5, they all have the same GroupID (even though visit 1 and visit 3 are more than 30 days apart, they are connected through visit 2). A GroupID doesn't change until either the PatientIllness value changes, or there is more than 30 days between visits. I can't tell from your question whether this meets your business needs, but it is how every grouper I've ever worked with does things.
It's probably not worth it for a spreadsheet with only 25K rows, but I'd be remiss if I didn't point out that there are commercial software packages that do grouping like this - often with quite sophisticated rules about how to group things. For example, different time periods for chronic vs. acute care conditions, different ways to decide which visits get grouped together, etc. I don't work for anybody that makes those, and I'm not going to link to anybody, but if you search for 'healthcare data grouper' you'll find a few things out there.
Hope this helps.
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