Calculate most recent payment date from multiple rows of payment information in excel - excel

My data are in the following format:
This information is regarding accounts that have been outsourced to a collection agency. As you can see, we have multiple rows for each agency, and multiple rows for each date in which those accounts were withdrawn and assigned. For example, the first agency, Bob Agency, was assigned on 3/12/15, withdrawn on 6/12/15, and assigned to Carla Agency on 6/30/15. Each agency is shown in a different column, and the first two corresponding columns in "Agency Date" refer to their assignment and withdrawl. If the cells are blank, that means that the accounts have not been withdrawn/assigned respectively.
I want to calculate the difference in days between when the account is assigned to any given agency, and the date of the most recent assignment. So using the previous example, the difference between 6/30/15 and 3/12/15.
My problem is that I can't work around the blank dates. Some accounts have multiple assignments and withdrawals, and others have just one.
Thank you for your help!

Assuming column L is empty, place this formula there:
=IF(MAX(G2:K2)=0,TODAY()-F2,MAX(G2:K2)-F2)
It will calculate the most recent assignment date and subtract it from the initial date. If no re-assignment date is there, it will use today's date.

Related

Excel: Count distinct numerical values if string condition matches

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.

How to create excel pivot table measure that calculates the value in a table at the end of the month

Given a set of data similar to:
which is a journal of account balances, some of which may be from statements, some may be manually entered. The key issue is that the data may be sparse, because my savings account only provides a statement once a quarter. In addition, balances are on different days of the month. It might even be possible to have two entries for the same account in a given month.
What I want to do is to create a measure that calculates the balance of each account on the last day of the month using the most recent value for that account prior to the end of that month.
I simulated this in the following table using max for the measure, which works for account/month pairs with a single value.
it doesn't fill in the previous value for missing values
max is not a valid measure if there is more than one value for the month.

Efficiency question with excel using index match for each cell in a large sheet

I have a 4 types of customers, each pay in a different payment plan.
group 1 - monthly
group 2 - semi monthly
group 3 - bi weekly
group 4 - weekly
I have a sheet with a range of all the relevant payment dates for those group sorted in the right order in row 1
I would like that for each customer there will be a data validation list (group 1,group 2, group 3,group 4)
When selected the customer's row will populate on the correct dates according to his group number and the date the payment starts.
My work around to do that was to create 4 separate sheets for each group, auto populate from the correct date and run it for all customers in each group meaning you can see for John Doe what and when will be his payments in each group even though he is in group 3 for example. And a MAIN sheet where John Doe has group 3 selected where a MATCH and INDEX is running to find when he is supposed to pay and how much. The issue is that for 400 rows and 300 column this becomes heavy.
How would you go about solving that?
each cell looks like this in the MAIN sheet
=LET(mothlydate,Monthlyrd3!$BK$3:AAC$3,semidate,Monthlyth16!$BK$3:ZZ$3,namemonthly,Monthlyrd3!$BK79:AAC79,namesemi,Monthlyth16!$BK79:ZZ79,
IF(OR($BA96="Monthly 3 rd",$BA96="Semi-Monthly",$BA96="Monthly 16 th"),
IF((IF(IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")>$AE96,$AE96,IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")))=0,"",(IF(IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")>$AE96,$AE96,IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")))),
IF($BA96="Bi-Weekly 1",(IFERROR(INDEX(NewBiWeekly!$BK79:AAC79,1,MATCH(GH$2,NewBiWeekly!$BK$3:AAC$3,0)),"")),IF($BA96="Bi-Weekly 2",(IFERROR(INDEX(NewBiWeeklyTwo!$BK79:AAC79,1,MATCH(GH$2,NewBiWeeklyTwo!$BK$3:AAC$3,0)),"")),IF($BA96="Other",(IFERROR(INDEX(NewOther!$BK79:AAC79,1,MATCH(GH$2,NewOther!$BK$3:AAC$3,0)),""))))))
)
THANKS!!!
This is based on a purely textual analysis of your formula, since data required for a meaningful analysis hasn't been forthcoming:
the expression below occurs 4 times in your formula
IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")
as does this one
IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0))
which means that, in the worst-case circumstances, one or both expressions are being evaluated on FOUR separate occasions - it would be sensible to consider making one or both of these named 'values' at the start of the LET() function, such that, in the worst-case cirumstances going forward, each would be evaluated only once.

Counting, filtering, conditioning command in Excel

I am trying to solve this question. The question is:
A sport store target is to provide at least one employee per 10 customers and at least one administer officer per 10 customers. The store checks those figures running a report on the first Friday of the Month every 30 days.
I have added an example of the data. I am trying to identify the months during which the store failed to achieve those figures?
I would appreciate if anybody can help. please see the picture bellow.
=LET(data,FILTER(A:B,(A:A<>"")*(ROW(A:A)>1)),a,INDEX(data,,1),b,INDEX(data,,2),u,UNIQUE(a),x,--(TRANSPOSE(a)=u),mmlt1,CEILING(MMULT(x,--(b="customer")),10)/10,mmlt2,MMULT(x,--(b="SECURITY")),mmlt3,MMULT(x,--(b="administer officer")),FILTER(u,(mmlt3<mmlt1)+(mmlt3<mmlt2),"all correct"))
I took column A for WEEK_ENDING and B for ROLE
You can replace FILTER(A:B,(A:A<>"")*(ROW(A:A)>1)) with your actual data (without headers).
I than took the unique dates and calculated
the count of "customer` matching the date (mmlt1)
the count of SECURITY matching the date (mmlt2)
the count of administer officer matching the date (mmlt3)
I rounded up the customer count to the nearest 10 and then divided by 10.
Now either of the mmlt2 or mmlt3 values should be larger than the count of mmltq (round up & divided by 10) to meet the conditions.
Finally I filtered the unique dates to the conditions. The result spills the dates where either too little security was available per 10 customers, or too little administer officers.

Count of customers scheduling service dates in consecutive years

I am brand new to Spotfire (using 7.7) and am hitting a roadblock on a simple task so am hoping for some assistance.
I need a count of customers that are scheduling service dates in consecutive years.
Since users will be using different date filters I created a MaxServiceDate calculated column to give me the max date depending on the filter and from there subtract a year to give me a PreviousYear calculated column.
Then my thought is then do a distinct count of all CustomerIDs which have a ServiceDate that match the MaxServiceDate and PreviousYear. The issue I'm running into is I don't know how to group by or fix the CustomerID in order to loop through the ServiceDates and check if they have dates matching my criteria.
Thanks for any help.
Sample data:
You can create a secondary table with a pivot transformation having the max(ServiceDate) and customer ID. The join that table back with your original so that you have the maxdate for each customer on your main table. Then do a calculated column based on the Max(ServiceDate) and Service date to determine if > 365 days.
Pivot Transformation
I think a calculated column like the following would meet your needs:
If((Max(Year([ServiceDate])) over (Intersect([CustomerID])) - Min(Year([ServiceDate])) over (Intersect([CustomerID])) + 1)=UniqueCount(Year([ServiceDate])) over (Intersect([CustomerID])),"good","bad")
For each customer, take their max service date year and subtract their min service date year and add +1. This number should match the number of distinct years associated to that customer's service dates.
This will tell you if a particular customer (at least while you had that customer) had service done in consecutive years or not.

Resources