Formula to find out how many times accounts transacted on the same day - excel-formula

I am looking for a way to find out which accounts appear to transact on the same days together the most.
I have looked into using the correlation function, but decided this would not provide the results I am looking for as I would need to be able to do this among the 6000+ different acct #s. Therefore, I have decided to try to solve this by creating a matrix of the account #s and finding out how many times each account transacted on the same day as another account, but I am open to other ideas of solving this if anyone has a better idea.
My source data is a large dataset consisting of 2 columns - Date (Column A) and Acct # (Column B).
I am currently looking into sum product, but since I do not want to look at any specific date, rather the date range as a whole, I am not getting what I want.
=sumproduct(('Trxs'!A:A='Trxs'!A:A)*('Trxs'!B:B=A$2)*('Trxs'!B:B=$a2))
What I am looking for would be a formula that I could use to pull across a matrix of the acct #s that would add up the number of times each of the 2 acct #s transacted on the same date over the time span of a month and not using a specific date to figure this out by.
1/1/2019 123456
1/1/2019 987654
1/2/2019 987654
1/3/2019 123456
1/3/2019 123456
1/3/2019 987654
1/3/2019 567890
and the outcome would be
123456 567890 987654
123456 3 1 2
567890 1 1 1
987654 2 1 3

I've came up with a solution using a helper table that counts if that account had activity that day:
The formula for the cell F12 on the helper table is:
=+IF(COUNTIFS($B$3:$B$12,$E12,$C$3:$C$12,F$11)>0,1,0)
And the formula on the Final Resul table:
Edit 2: I agree with Domenic, the formula on cell F4 works better with the IF section:
=IF($E4<>F$3,SUMPRODUCT(INDEX($F$12:$J$14,0,MATCH($E4,$F$11:$J$11)),INDEX($F$12:$J$14,0,MATCH(F$3,$F$11:$J$11))),COUNTIF($C$3:$C$12,$E4))

Related

Formula that looks for values in two columns in order and calculates the average in the third column

So I have three columns, A (Country), B (Status), and C (transit time). Below is an example:
Country status transit time
Slovakia Transit 2
Hong Kong Delivered 1
New Zealand Transit 2
Barbados Transit 2
Peru Transit 2
Ecuador Transit 2
Greece Transit 2
New Zealand Transit 4
I was hoping to see if there are two formulas. The first formula would match Column A and return the average in Column C as the value. Using the example above, if I wanted to know the average transit time for New Zealand (which is 3 days in this example). The other formula I was looking for is one that return the value of all shipments over the average transit time (that was found before). For example, I know the average transit time to New Zealand is 3 days, but I also want to know how many shipments exceeded the average 3 days (in this example, it would be 1 shipment).
Here is a sample sheet with the method that Scott identified in the comments:
https://docs.google.com/spreadsheets/d/1mKwLtwnOZaWzj2zWV71_hKVg76GRB_4ou_4KrHhDuxw/edit?usp=sharing
The first formula, in F2, is like this:
=AVERAGEIF(A$2:A$9,E2,C$2:C$9)
which calculates the average transit time for the shipments to each country.
The second formula, in G2, is:
=COUNTIFS(A$2:A$9,E2,C$2:C$9,">"&F2)
which counts the number of shipments to each country where the transit time is greater that the average.
See here:
Let us know if you are still having an issue using the two functions Scott suggested.

Dynamically sum cells whose neighboring cell contains certain text

In my spreadsheet, I am tallying expenses made by John, Bob, and Simon for a project.
When John records an expense, it must contain his name (not case sensitive):
A B
Apples(John) 50
Simon makes 90% of the expenses and doesn't always write his name down.
At the end of the project, an expense list might look like this:
A B
Apples(John) 50
Toy (bob) 15
Pencils John 30
Metal 10
Peaches (simon) 5
Donuts BOB 30
Without using macro's (which don't work on Android's Excel app), how can I dynamically sum their expenses as each new entry is entered?(I am logging expenses on the desktop and on the phone, synced through the cloud). I would like one cell for each team members total. This is tricky for me because I have to sum items in B if its corresponding entry in A contains a certain text. Something like:
Totals:
John 80
Simon 15
Bob 45
SUMIF() function will meet your requirement. You have to use wildcard in criteria part as names are mixed with item name. Try below formula.
=SUMIF($A$1:$A$6,"*" & D1 & "*",$B$1:$B$6)

Count Unique Entries in a Month for Pivot Table

Good afternoon,
I'm currently working on setting up a pivot table for chart that outlines an Average Revenue per Person by Line Type. Using the pivot table, I can sort everything out, but when I try to get a count of person, it adds all instances of that person's name up. What I want is that if the person's name appears once in a month, all other instances in that month of the person's name are not counted. But during a new month, the person's name will appear once more. So, it is somewhat like a unique count, but only unique per month.
My excel table looks something like:
A B C D
Date Person Revenue Line Type
1/1/2015 John $100 Toy
1/6/2015 Phil $200 Toy
1/6/2015 Jane $25 Garden
1/7/2015 John $50 Electronics
1/25/2015 John $10 Electronics
2/1/2015 John $10 Toy
2/17/2015 Phil $30 Garden
2/20/2015 Bob $500 Electronics
2/21/2015 Jane $100 Garden
So, as you can see, a person's name can occur more than one time in a month, and in more than one month. Currently, the code I am using for my helper column (E) is:
=1/COUNTIF($B:$B,B2)
This has only been giving me a count of patients throughout the entire year, not taking new months into account. I also have attempted this formula:
=IF(SUMPRODUCT(($B$2:$B2=B2)*($A$2:$A2=A2))>1,0,1
This only counts values that occur on the same day. I've tried adding in MONTH() checks and such, and am only getting syntax errors. I'm not sure where to turn for this one. Thank you!
Thanks to #TomSharpe's advice, I added a helper column to concatenate Month/Date and the Patient's name like so:
=MONTH(A2)&"-"&B2
Then used the original formula (below) to COUNTIF divided by 1.
=1/COUNTIF($B:$B,B2)
This gave me exactly what I needed.
Thanks again!

Lookup with multiple criteria, one a MAX value

I am trying to lookup the LOCATION of an employee (NAME) and their MANAGER from the most recent month (largest month number) in a particular QUARTER in data like this:
NAME LOCATION MANAGER QUARTER MONTH
Ryan Smith Sioux Falls Rick James 3 7
Jane Doe Tampa Bobby Brown 3 7
John Rogers Tampa Tracy Lane 3 7
Ryan Smith Sioux Falls Rick James 3 8
Jane Doe Denver Thomas Craig 3 8
John Rogers Tampa Cody Davis 3 8
So if I know the name of the employee and the quarter I'm looking up, the results should display who their last manager was and the location they were in, as these may change month to month.
I have used an INDEX and MATCH array formula:
{=INDEX($B$2:$B$7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0))}
but this just provides the first match and not necessarily the most recent month in that quarter. I attempted to include a MAX function which looked something like this:
{=INDEX($B$2:$B$7,MAX($E2:$E7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0)))}
but that didn't quite get me there either.
What formula do I need to get this to work?
I think I'd choose a PivotTable for its versatility and speed:
I think a pivot table is probably the best option and can easily be modified with the filters when new entries are added to the underlying data. I was working on a solution with a formula, but it requires you to add a lookup column.
The formula for the lookup column is: =E6&" "&H6&" "&I6
I wasn't clear on how the OP was going to be "entering" his employee name and quarter, so I had to make an assumption that it would be in a separate column:
And the formula in column B (which is cumbersome) is:
=VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,3,FALSE)&", managed by "&VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,4,FALSE)
But it works, and as long as the lookup range is adjusted, is scaleable.

Count the number of absent in different sheet excel

I have 6 worksheets and each containing names of workers. The first sheet just picks data from the other five sheets each representing a week day. The other five sheets contains names of workers which is in a column A, their working hours in column B and column C is whether they are absent or not. I want a way to collect information to the first sheet such that there will be a column that will count the number of days a worker has being absent.
When a worker is absent it is marked "absent" else it is left blank.
Can I use it with VLOOKUP included?
You should be able to use a "=COUNTIFS(criteria_range1,criteria1,criteria_range2,criteria2,etc.)"
statement which might look something like: "=COUNTIFS(WorkerNameRange,WorkerName,AbsentColumn,AbsentIndicator)"
or
"=COUNTIFS(ColumnA,WorkerName,ColumnC,AbsentIndicator)"
Okay, you didn't provide a lot of information, so here is my best answer based off of some made up sample data.
We will use 3 workers, George, Bob, and Steve. George works 8 hours/day, Bob 6 hours/day, and Steve 4 hours/day. So this is what I assume the Monday sheet would look like
Monday
Bob and Steve both missed work (rough weekend), so we won't count their hours on the Total sheet. We will also count this as 1 absent for both.
Worker Hours Absent
George 8
Bob 6 absent
Steve 4 absent
Tuesday
Tuesday is similar to Monday except that only Steve was absent.
Worker Hours Absent
George 8
Bob 6
Steve 4 absent
Total Sheet
We will assume that no one was absent for the rest of the week. So George should have gotten in 40 hours with 0 days absent. Bob missed a day, so he only got in 4*6=24 hours. Steve missed two days, so his hours will be 3*4=12. Bob will have 1 absent and Steve will have 2.
Worker Hours Days Absent
George 40 0
Bob 24 1
Steve 12 2
To sum up the hours they were present, we can use the following formula in the Hours column on the Total sheet.
=SUMIFS(Monday!$B$2:$B$4,Monday!$A$2:$A$4,Total!A2,Monday!$C$2:$C$4,"")+SUMIFS(Tuesday!$B$2:$B$4,Tuesday!$A$2:$A$4,Total!A2,Tuesday!$C$2:$C$4,"")+SUMIFS(Wednesday!$B$2:$B$4,Wednesday!$A$2:$A$4,Total!A2,Wednesday!$C$2:$C$4,"")+SUMIFS(Thursday!$B$2:$B$4,Thursday!$A$2:$A$4,Total!A2,Thursday!$C$2:$C$4,"")+SUMIFS(Friday!$B$2:$B$4,Friday!$A$2:$A$4,Total!A2,Friday!$C$2:$C$4,"")
What this does is uses a series of SUMIFS() functions to check each day if the name matches and if they were absent. If they weren't absent, it adds their hours to the total. If they were absent, it does nothing. So we get the correct hour totals. We could just count the absents and then do some math with the number of days absent, but I don't know if you have people who might work different hours different days (e.g. 4 hours Monday, 6 hours Tuesday, etc.)
To count the hours, we will use a simple COUNTA() function.
=COUNTA(Monday!C2,Tuesday!C2,Wednesday!C2,Thursday!C2,Friday!C2)
This counts all cells in that workers Absent columns that are not blank. This allows you flexibility to use any mark for absent as long as blank means "not absent".
There are other ways this spreadsheet could be made more robust with Table formatting, but I will leave it up to you to do the research.

Resources