Pulling Unique Data from a Table A Certain Number of Times (Advanced) - excel-formula

I don't think this problem is actually very difficult. But I'm stumped. If you can take a look for me I'd really appreciate it.
Basically, I need to summarise all the labour hour costing for each month. I have a list of staff who, for their work each day, record the: jobs, codes for that job, and hours for that.
Sample Source Data:
Datestamp Name Job 1 Code 1 Hours
18/08/2017 Chainz Graham 247 - Dixon Stage 5 08-Other
19/08/2017 Jury Herewini 252 - Kay Rd Cutdown 02-Roading 8:00:00
20/08/2017 Adam Young 247 - Dixon Stage 5 08-Other 3:00:00
21/08/2017 Adam Young 250 - 132 Kay Rd Subdivision 03-Stormwater 9:30:00
22/08/2017 Jury Herewini 250 - 132 Kay Rd Subdivision 03-Stormwater
23/08/2017 Adam Young 250 - 132 Kay Rd Subdivision 02-Roading
At the end of each month I want to sum all the hours assigned to each code so that I end up with a tidy list.
Sample Desired Projected Data:
Adam Young 250 - 132 Kay Rd Subdivision 02-Roading 43
Adam Young 250 - 132 Kay Rd Subdivision 03-Stormwater 17
Adam Young 252 - Kay Rd Cutdown 03-Stormwater 40
Chainz Graham 250 - 132 Kay Rd Subdivision 02-Roading 38
Chainz Graham 250 - 132 Kay Rd Subdivision 03-Stormwater 42
Connor Herewini 250 - 132 Kay Rd Subdivision 06-Concrete 29
The difficult thing is that I only want the name, project and code to appear if the worker had hours assigned to that code for the month. So in the final list, I want three Adam's to appear if he worked on three different job codes, and so on for jobs and codes.
Please don't worry about the hours column, a simple SUMIF function can get that job done. I can also get the correct number of names to come up easily, but the project and code I'm having trouble with.
Here's a sample spreadsheet to work with below which you can download:
https://drive.google.com/file/d/0B3g...ew?usp=sharing
You will see the method I am attempting by the intermediate data in the sheet. You may find a better solution and ditch that method altogether. I'm open to suggestions.

I couldn't download your spreadsheet so not sure how your data look like in there. With the data provided here, I came up with this array formula (Please click Ctrl + Shift + Enter together)):
=IFERROR(INDEX($B$2:$E$7,SMALL(IF($B$2:$B$7=$G2,ROW($B$2:$B$7)),COUNTIF($G$2:$G2,$G2))-1,MATCH(H$1,$B$1:$E$1,0)),"")
I had the formula entered into cell H2 so please adjust it based on your layout. You can then drag it to cover all other fields. And here is the screenshot of how it looks like in the outcome:
P.S. Hours column may show in a different format and you will need to update that as well. Hope this can help you get start with your task.
P.P.S. I assume you will have the name ready for lookup or match on column G.

Related

Sort one data set to get the best fit with another data set

I'm currently working on an Excel program to manage employees at the checkout counters at a larger supermarket. It will load the employees' work schedules from an online database and then place the employees at the different counters.
Currently I'm at a point where I have loaded the schedules and divided the employees into the day shift and the evening shift in a sheet looking like this (only with much more people in reality):
A B C D E F
1 Name1 0745 1615 Name5 1515 2130
2 Name2 0830 1600 Name6 1600 2230
3 Name3 0915 1615 Name7 1630 2230
4 Name4 1000 1530
where 0745 is 7:45 and 1615 is 16:15 (4:15 PM)
Now, I would like to match a person from the day shift with a person from the evening shift so that ideally there will be a 15 minute overlap between all of them. As in the example above it is not necessarily given that there are equally as many people in the day and the evening shift, neither it will not necessarily be given that there can be an overlap of exactly 15 minutes between all teams of two. In this case, an overlap of 30 minutes is better than an overlap of 0 minutes for instance.
My own idea is to try all possible combinations of matches between the two data sets and then assign different error values to the different kinds of overlaps so for instance an overlap of 15 minutes yields a value of 0, 30 minutes yields 1, and 0 minutes yields 2, and then the best match is the one with the smallest total error.
However, I have no idea how to program this in VBA or if this is even the best approach.
I have tried searching the forum, but I didn't find anything helpful unfortunately. I hope one of you can help me or have an idea where I can search.
I think there's a lot of thinking behind the answer to your question. Writing the code for this is a bit of a project, in my opinion.
You could make your life a little easier by sorting columns A-C ascending by column C and sorting columns D-F ascending by column D. If you're not working with a lot of employees, your answers will kind of fall out of that. (In your sample data set, it becomes immediately clear that Name4 is paired with Name5 and Name1 or Name3 is paired with Name6.)
It's not a complete answer, but maybe it's a start.

Excel - Is it possible to create nested 2D stacked bar chart?

I'm trying to create a "nested" 2D stacked bar chart in excel but I only got until stacking the columns. Unable to show "work %" inside "Used %". Is there a way to accomplish this in excel? I seen a similar example but that was in BI and not in excel.
Update:
Please note that "Work" is a subset of "Used".
Total =100 & Used = 50, then Used % = 50%
Used = 50 & Work = 50 , then Work % = 50% (of Used).
Hope this clarifies.
Name Type Total Used Work Used % Work %
Mike Sport1 100 50 25 50 50.00
Mike Sport2 175 75 50 42.86 66.67
Mike Sport3 50 40 10 80 25.00
Mike Sport4 200 110 40 55 36.36
Rita Sport1 75 25 10 33.33 40.00
Rita Sport2 150 100 80 66.67 80.00
Rita Sport3 100 75 35 75 46.67
Rita Sport4 125 100 80 80 80.00
I'm suggesting an approach further down, but your question needs a lot of clarification. The clarification would normally go into a series of me writing comments and you responding by editing your question and providing more details.
I don't feel like going through this rigmarole right now, so, please read my questions for clarification, try to understand what I'm after and then go and edit your question to provide the required detail.
My questions to you:
What is the information you want to derive from the data? What question are you posing to the data that the chart should answer?
Your data table does not make sense. The "total" column totals --what exacty--? How come "used" is 50 and "work" is 25 but Used% is 50 and Work% is also 50?
Name Type Total Used Work Used % Work %
Mike Sport1 100 50 25 50 50.00
Please edit your question and either amend the data or explain how it all hangs together.
What data do you want to chart? The scribbles on your scan are less than conclusive.
My suggestion:
These questions aside, you can create a stacked column chart with the data you want to display. You may need to create a helper table as the data source for the chart, just so everything is in the correct place for easy selection and rendering.
Whether or not something is a percentage or part of a bigger unit can be shown by formatting the colors of the data points, and with data labels.
You can add data labels to any series and then edit the labels to receive their values from spreadsheet cells. The whole thing can be automated with VBA.
If you don't want to write that kind of VBA yourself (which is understandable) you can download the free XY Chart Labeler tool by Rob Bovey here. It is ill-named and can actually add labels to any chart type.
I'm aware that this is not a complete answer. I expect you to edit your question with the missing information, so I can subsequently edit my answer to supply a real answer.

systems of equations and lowest common multiple

You need 100 lbs of bird feed. John's bag can carry 15 lbs and Mark's bag can carry 25 lbs. Both guys have to contribute exactly the same total amount each. What's the lowest number of trips each will have to take?
I have calculated this using systems of equations.
15x + 25y = 100
15x - 25y = 0
This equals out to:
John would have 3.33 trips and Mark would have 2 trips. Only one problem: you can't have 1/3 of a trip.
The correct answers is:
John would take 5 trips (75 lbs) and Mark would take 3 trips (75 lbs).
How do you calculate this? Is there an excel formula which can do both layers of this?
Assuming you put the total bird feed required in A1 and John's and Mark's bag limits in B1 and B2 respectively, then this formula in C1:
=MATCH(TRUE,INDEX(2*ROW(INDIRECT("1:100"))*LCM($B$1:$B$2)>=$A$1,,),0)*LCM($B$1:$B$2)/B1
will give the lowest number of trips required of John. Copying this formula down to C2 will give the equivalent result for Mark.
Note that the 100 in the part:
ROW(INDIRECT("1:100"))
was arbitrarily chosen and will give correct results providing neither John nor Mark is required to make more than twice that number of trips, i.e. 200. Obviously you can amend this value if you feel it necessary (up to a theoretical limit of 2^20).
Regards
Since John and Mark need to carry the same total amount of bird feed, what they will carry has to be a multiple of the least common multiple.
Since they both carry that amount the total amount will always be an even multiple of the LCM.
So find the least even multiple of the LCM that is larger than 100. And calculate the number of trips John and Mark will have to take from that.
For John:
CEILING(100/(2*LCM(15; 25));1)*LCM(15;25)/15
For Mark:
CEILING(100/(2*LCM(15; 25));1)*LCM(15;25)/25

Add hours together using VBA

I have an excel sheet that displays the total number of regular hours and overtime hours in excel. I am trying to figure out how to add them together to get a Total hours worked in a month the excel sheet looks like the following
E00XXXX James Smith 160:00 19:52
E00XXXX John Doe 160:00 19:52
E00XXXX Sue Patterson 160:00 19:52
I am trying to add the last two columns together to get something like this
E00XXXX James Smith 160:00 19:52 179:52
E00XXXX John Doe 160:00 15:22 175:22
E00XXXX Sue Patterson 160:00 10:47 170:47
I don't have any code to try, because I honestly don't even know where to start. I would also like to state that this has to be done within a VBA and that I do not have control over the format in excel.
To automatically format times that when added together exceed 24 hours, 60 minutes, or 60 seconds, you can use the following custom number formats and the SUM function in Excel:
Hours = [h]:mm:ss
Minutes = [m]:ss
Seconds = [ss]
Source

How to automate moving words in excel in the same column

I'm not good with excel, my knowledge is very limited, but I'm stuck with a project where I have 3,077 rows. There are a few columns where I need to move around a few words or numbers. All I need right now is to know how to do it in one column, or if it's even possible. I have a list of addresses and 90% of them have been entered incorrectly. Rather than go through each one one by one I'm hoping there's something I can run to swap the word or number around. If need be I can create a new column.
Below is an example. The first two are correct, the next four are not. I need the second number to be after ROAD or after HWY. i.e. 6 ROAD 3066 or 1059 HWY 516. Thank you for your help in advance.
42 ROAD 3050
68 ROAD 3400
6 3066 ROAD
1059 516 HWY
986 516 HWY
33 3403 ROAD
If I understand correctly, your task is as follows:
your have three columns
one of them is not a number
you want to have them in order number/text/number
Your input cells are A1/B1/C1. Then create the following additional columns:
D1 = IF(ISNUMBER(A1);A1;B1)
E1 = IF(ISNUMBER(A1);IF(ISNUMBER(C1);B1;C1);A1)
F1 = IF(ISNUMBER(C1);C1;B1)
Those are then the desired output columns.

Resources