Excel Sum Similar Rows via Macros - excel

I found an answer similar to my question on these boards. However, my data is setup differently and I wasn't getting the results I needed.
My data in Excel looks like the following:
ParcelNumber BillNumber OwnerName Code Year DollarAmount
111222 9117222 Smith, Bill 22 2013 $999
111222 9117222 Smith, Bill 22 2013 $276
111222 9117222 Smith, Bill 22 2013 $100
111223 9110001 Tan, Steve 22 2013 $96
111223 9110001 Tan, Steve 22 2013 $12
111224 9112396 Bishop, John 22 2013 $126
111225 9113333 Fidel, Jason 22 2013 $990
I need to do the following:
For all of the Parcel numbers that are the same, total up the Dollar amount and consolidate one one line per parcel number. The output would look like this:
ParcelNumber BillNumber OwnerName Code Year DollarAmount
111222 9117222 Smith, Bill 20 2013 $1375
111223 9110001 Tan, Steve 20 2013 $108
111224 9112396 Bishop, John 20 2013 $126
111225 9113333 Fidel, Jason 20 2013 $990
Thank you very much.

Warning: Quite a lot of images coming...
Okay, select your entire table and go to Insert > PivotTable and click OK in the wizard.
Click, drag and drop all the fields but the last one from the right pane to the box in the lower left. The last field goes in the box in the lower right. You should get something like this:
Go to PivotTable Design and in Layout, pick Show in Tabular Form and Do not show subtotals.
And you should be done! You can copy the information you need to another sheet as required.
If the amounts aren't displaying properly, make sure that the calculation is "Sum" and not "Count". You get "Count" as default if there is a non-numeric cell in the column you are pivoting. To change the calculation, simply right click on any number in the pivot table, go to 'Summarize data by' and check 'Sum'.

Related

Sum product for all the months if 2 tables match

So I have this issue, I have two tables one is employees, and another one is the projects.
Employees Table:
Year Name Type Jan Feb
2018 Kevin Salary 5000 2000
2018 Kevin Insurance 200 400
2018 Alex Salary 3000 4000
2018 Alex Insurance 300 400
Projects Table
Year Project_Name Employee_Name Jan_Hours_Worked Feb_Hours_Worked
2018 Apple Alex 7 5
2018 Apple Kevin 5 0
2018 LG Kevin 0 3
Now I am creating a result list of all the projects and costs recurred for them, what I need is for each project in Table 2 to find which employees are involved and then use that to find related costs for the employee from the Table 1 and calculate total costs for that project.
(e.g for project LG, I have Kevin working on that in Feb,for him company paid 4400(salary+insurance) in Feb and the costs recurred for the LG project would be 4400 divided by hours spent on the project which Kevin in total spent 3 hours; e.g.2 for the project Apple it would be the same but sum of Kevin's and Alex's costs from Jan and Feb, so Kevin: 5200/5 + Alex:3300/7 + 4400/5)
Now I have the formula to calculate this for 1 months which is something like this
=SUMPRODUCT(SUMIFS(Employees[Jan], Employees[Name],Project[Employee_Name], Employees[Year], 2018 )/Project[Jan_Hours_Worked],--(Project[Project_Name]=K14))
I need to find how to get the yearly result per project without repeating the formula 12 times, also with this formula, i get div to 0 error when an employee didn't work on particular months, so that needs to be sorted somehow. Any Help?
I suggest you to change how you store your data. If you can make some minor changes, then you can have an easy way to get the information you want, and also a Pivot Table with a summary of cost recurred for each proyect and which employee generated that cost.
IMPORTANT: For this answer to work, you must make sure that every Employee's Name is UNIQUE. If not, adapt the example trying to create
an Employee's ID or something.
Also, please, note i got a spanish version of Excel, so screenshots are in spanish but I will translate formulas :)
Ok, first of all, I changed the design of your table Employees. Creating a column for each month is kind of annoying. Use just a column to get the month. You can type the month in a cell just like 01/2018 and Excel will change it instantly to format mmm-yy (Jan-18)
This is how your Employees table should look:
The column TOTAL COST is just a sum of SALARY + INSURANCE. If you have any other concept, just add it as a column and modify the TOTAL COST COLUMN to include it.
Second, the table Project, I think it should be like this:
The column Employee Cost has an Array Formula.
IMPORTANT: Array formulas are inserted pressing CTRL+SHIFT+ENTER
The formula is (I used same names for tables, so copy-pasting should work for you):
=INDEX(Employees;MATCH(Project[[#This row];[Employee_Name]]&Project[[#This row];[Month]];Employees[Name]&Employees[Month];0);COLUMN(Employees[[#Headers];[TOTAL COST]]))
If you typed the formula right, you should see { at start and } at end.
The formula in Cost Recurred to Project is just a division of Employee Cost / Hours. Added an IFERROR when the hours worked are 0, then show 0.
=IFERROR(Project[[#This row];[Employee Cost]]/Project[[#This row];[Hours]];0)
And last step, your Pivot Table. Create one and organise it to get the sum per hours and month and proyect you want. You can get one like the one below:
As you can see,e.g. for project Apple, you can see that total cost is 2.391,43
but also you can see the cost of each Employee. Pretty cool I think.
I really hope you can modify the design of your data, because Excel is designed to work going down (I mean using rows) more than using columns. Excel 2007 got more than 1 million of rows and just around 16.000 columns, so it's designed to work vertically.
Hope this helps, or at least, give to you a clue of how to proceed :)

Searching for multiple items within a cell and returning one value

I am trying to find a way for excel to search through cells in a column of references with references separated in the cell by () and return only the most recent year of publication. I would like not to have to do this manually by going through 1000+ cells for 15 columns. Is there a way to do this? Row examples 1-7 below:
X (BFP 2013) (Burns 1982 [1,2,3,4,S,M,H,C]) (Rooney 1984 [5,6,11,S,M,H,C])
X (BFP 2013) (Burns 1982 [1,2,3,4,S,M,H])(Rooney 1984 [5,6,11,S,M,H])
X (BFP 2013) (Lortie et al. 1996) (Burns 1982 [1,2,3,4,S,M,C])(Rooney 1984 [5,6,11,S,M,H])
#N/A
#N/A
X (Burns 1982 [1,2,3,4,S,M,H])(Rooney 1984 [5,6,11,S,M,H])
X (BFP 2013) (Burns 1982 [2,4,M,H])(Rooney 1984 [5,6,M,H])
For example, in this case I would like to have the formula return 2013 for the first three rows, N/A would be fine for row 4 and 5 because there is no data , and return 1984 for row six and 2013 for row seven as they are the most recent publications.
I have a list of 18 years (publications) that I can search for within the cells. Not sure if a nested If function can pick out a year, if it occurs, within a cell and return the highest value of : 1901, 1927, 1938, 1978, 1982, 1983, 1984, 1985, 1990, 1994, 1996, 1998, 2004, 2005, 2007, 2010, 2012, 2013.
OR I am unsure if I can use an =IF(ISNUMBER(SEARCH and get it to recognize just the years within a string of text and return only the most recent year. Anyone have any ideas? I hope this is clear enough, it is very hard to describe.
Thank you for your time,
Mags
I would not like to try and do this with an excel formula as it really does not have good search and replace capability. You doubtless could do it with a macro but a more time effective to your solution might be
Cut and paste the column of data into a text editor which can do a grep search, like BBEdit or TextWrangler
Run a replacement which converts the text into a string of dates. The following more or less does what you want - search string: .*?([\d]{4}|\r) replace string \1, This gives you rows like this ,2013,1982,1984,
Run replacements to add "=max(" at the start of the line and ")" at the end thus giving you a text file consisting of rows such as: =max(2013,1982,1984)
cut and paste this back into excel
I find combining excel and BBEDit in this sort of way allows me to clean up data sets very effectively. If you need to repeat the same process then you can save the set of replacements as a text factory.
Assuming your first X is in A1, I suggest entering your 18 years, one each, into ColumnsB:S of a new Row1. In B2, copied down and across to suit:
=IF(ISERROR(FIND(B$1,$A2)),"",B$1)
in T2 and copied down to suit:
=MAX(B2:S2)
This will return 0 rather than #N/A but you could wrap the MAX function to test for 0 and if so return #N/A if required.
However I do not understand your reference to "for 15 columns". If that is fifteen times the data of the type in ColumnA it might be worth copying or moving such blocks into ColumnA and extending the range to which the formulae apply.
Not taking credit for the answer here but I noticed Mags (OP) already commented that he/she got the answer/working formula, I just wanted to highlight it since I missed it myself at first. a smart use of ROW() imho. definitely going to remember this one.
=MAX(IFERROR(1*MID(C3,ROW(INDIRECT("1:"&LEN(C3))),4),""))

EXCEL: multiple condition count and data listing/summary

I need to do a multiple condition count and data listing/summary in EXCEL.
I have an EXCEL file with the following:
A B C D <-- Columns
tennis Jan 4 Smith John
tennis Jan 4 Fellows Todd
tennis Jan 4 Biebs Justin
football Jul 8 Smith John
football Jul 8 Rucker Pete
tennis Aug 7 Smith John
etc...
I have to figure out by Last name/First Name (col D/col C), which activity they participated in (and it could be multiple times (ie - tennis on Jan 4 and Aug 7)).
I've researched VLOOKUP and countif and I can make them work on other files but I can't get them to work with this one. I know I could sort by names and manually count but trying to figure out a way to use multiple conditions to get the answer (without having to manipulate the file too much because it is not my file in terms of who is entering the information).
Any help is appreciated (even if it requires partial manual effort!) Anything is better than manually sorting the file multiple different ways.
Thanks!
-Dan
I suggest:
two extra columns in your source data. One (say wk) with =WEEKNUM(B2), the other (say bod) with =E2&", "&F2 and both copied down to suit.
a single pivot table (the fields can be rearranged to get different 'views' and/or filtered/sorted/grouped to suit)
If you find multiple activities for the same bod for the same wk, then click on the counts that are greater than 1 and the details should help to determine whether adding a flag may be appropriate, to distinguish camps.

Is it possible to pivot a table in excel and report all the values

I'm not sure this is possible but I'm trying to do the following in excel. I have a table with the names of people and the team they belong to, and I want to make a roster for each team. So I have something like this:
Michael Jordan Bulls
Dennis Rodman Bulls
Kobe Bryant Lakers
Steve Nash Lakers
And I want to get something like:
Bulls Lakes
Michale Kobe
Dennis Steve
Is there a strait-forward way to do this?
Create a PivotTable with both Team and Name as Row Labels and Show in Tabular Form. To show the teams side by side, copy and Paste Special Values the PT then select and drag one team to suit.

How do I Use Pivot Tables to Create One Line Per Sub Category

Forgive me if this is not the "the best" place to ask excel questions. I looked at the data analysis page and it looks like there aren't any real questions about excel in there.
I'm trying graph the sales of various products over a period of time. I'm pulling it from the database in the format
Sales Person | End of Month | Sales | Product Type
John Doe 1/31/2010 1,000 Widget A
John Doe 1/31/2010 2,000 Widget B
John Doe 1/31/2010 3,000 Widget C
John Doe 2/28/2010 5,000 Widget A
John Doe 2/28/2010 2,000 Widget B
John Doe 2/28/2010 3,000 Widget C
I then get a summary like:
Year | Month | Product | Total Sales
2010 Jan Widget A 1,000
Widget B 2,000
Widget C 3,000
Feb Widget A 5,000
Widget B 2,000
Widget C 3,000
The problem is that I'm wanting to graph The widgets as separate lines so that I can track sales against each other. Over time.
However, excel treats it all as one "total" and then shows 3 points on the graph for each month rather than showing 3 separate lines.
No matter how I manipulate it, I can't get it to make 3 separate lines.
The example above should show how it works with two products. I show how widget A and B are two points on the same line rather than belonging to two separate lines.
I have had success in the past for a different project when I hand entered information into a spreadsheet with the format of:
End of Month | Product A Sales | Product B Sales | Product C Sales
However, my current data is not in this format and it doesn't seem I can take the same approach...
Any help is welcome.
That is an excellent example for a pivot chart. Choose Insert->Pivot Table->Pivot Chart (Excel 2007). Afterwards select your original table. Then use "End of Month" for the rows, "Product Type" for the columns, and "Sum of Sales" for data. Excel will then automatically create one line per widget type (if line is not selected as default graph type you may have to change the chart type).
Based on your description, I think what you need might be a chart like this, the X-axis would be months while within each month, there would be several bars representing data of different widgets. Here I made an example based on your data.
As for data format, you should do some preprocessing to arrange your data into several (three in this case) subsets, each subset contains monthly sale data for a widget. It could look like the format below.
Jan Feb
WidgetA 1000 5000
WidgetB 2000 2000
WidgetC 3000 3000
As you could see, this is not an original Excel chart, I actually made this chart with the Funfun Excel add-in. This add-in allows you to use JavaScript directly in Excel so you could use powerful libraries like Chart.js or D3.js to make charts. Here in this example, I used Chart.js to create this chart.
Funfun also has an online editor which allows you to test your JavaScript code. For this example, you could check the details of the code on the link below.
https://www.funfun.io/1/edit/5a25653acf76561801b732b4
If you are satisfied with the result, you could easily load the result into your Excel using the URL above. Here are some screenshots of what it looks like.
Disclosure: I'm a developer of Funfun.
You can reorder the columns in the Pivot Table:
| Product | Month-Year | Total Sales
Widget A Jan 2010 1,000
Feb 2010 5,000
Widget B Jan 2010 2,000
Feb 2010 2,000
Widget C Jan 2010 3,000
Feb 2010 3,000
That would make it easier to create three series, one for each widget. Make the chart an X-Y chart and the series will line up.

Resources