Grouped Sum on complicated calculated fields in other column - excel

I have an excel sheet with data (Sheet1). First number is a secuencial number representing a number of month.
Sheet1 <month, year, data1, data2>
[first row: titles]
1 1 data11 data12
2 1 data21 data22
3 1 data31 data32
4 1 data41 data42
5 1 data51 data52
6 1 data61 data62
7 1 data71 data72
8 1 data81 data82
9 1 data91 data92
10 1 data101 data102
11 1 data111 data112
12 1 data121 data122
13 2 data131 data132
14 2 data141 data142
Sheet2
[month, year, formule]
1 1 sheet1!C2-3*sheet1!B1
2 1 sheet1!C3-3*sheet1!B2
3 1 sheet1!C4-3*sheet1!B3
4 1 sheet1!C5-3*sheet1!B4
5 1 sheet1!C6-3*sheet1!B5
6 1 sheet1!C7-3*sheet1!B6
7 1 sheet1!C8-3*sheet1!B7
8 1 sheet1!C9-3*sheet1!B8
9 1 sheet1!C10-3*sheet1!B9
10 1 sheet1!C11-3*sheet1!B10
11 1 sheet1!C12-3*sheet1!B11
12 1 sheet1!C13-3*sheet1!B12
13 2 sheet1!C14-3*sheet1!B13
14 2 sheet1!C15-3*sheet1!B114
Sheet3
[year, Sum of column C in sheet2 grouped by year]
Firts row <year,formule>
1 =SUMIF(sheet2!B$2:B$15, A2, sheet!C$2:C$15)
2 =SUMIF(sheet2!B$2:B$15, A3, sheet!C$2:C$15)
My question, Can I remove and do the calculation in Sheet3
I can if the column C of sheet2 is moved to sheet1 but I don't want to put many columns in sheet1 because Sheet2 has many columns. If we can remove Sheet2, we removing a lot of formula (in this example 14 + 2 formules -> only 2 formules)
Thanks

Solved: The year is in column 2 then
=SUMPRODUCT((Sheet1!B$2:B$424=Sheet3!B2)*(Formula using $2:$424 in each column of the mensual formula))

Related

Excel - Shift starting column right by x

In excel I have a dataset. This represents how much stock of 2 products is sold in the first, second, third, etc... month of the product being on the shelves (starts in A1):
Month 1 2 3 4 5 6 7 8 9 10 11 12
Product 1 3 5 2 1 6 1 2 4 7 2 1 5
Product 2 2 1 5 6 2 8 2 1 2 3 4 9
However, the first product sales do not always occur in month 1. They occur in month X. Is there a way (not VBA or copy and paste) of shifting the entries right by 'x' so they align with the month.
Example for data above
Product 1 starts in month 2
Product 2 starts in month 5
Month 1 2 3 4 5 6 7 8 9 10 11 12
Product 1 0 3 5 2 1 6 1 2 4 7 2 1 5
Product 2 0 0 0 0 2 1 5 6 2 8 2 1 2 3 4 9
*0 not required (great if possible), but more for illustration
Thanks
I have created a simple example that does the same job. The shown formula is copied over the shown cells in the row of new data. (The number '2' in the formula refers to the column number of the starting data cell which is column B, hence 2.)

how to map/pull column in 1 sheet based on another to repeating values in excel?

I have excel sheet with repeating ids
id jun19
1 3
2 2
3 7
1 3
2 2
3 7
1 3
2 2
3 7
i want to append another column 'jul19' from another sheet.
that jul19 sheet has all and even more ids:
id jul19
1 4
2 6
3 45
4 7
5 9
it should take only those that have the id and pull values from column 'jul19'.
the end result is this:
id jun19 jul19
1 3 4
2 2 6
3 7 45
1 3 4
2 2 6
3 7 45
1 3 4
2 2 6
3 7 45
how to do this? how to pull corresponding values from column "jul19" based on the id?
I tried to do this in pandas, but failed.
Assuming table1 is in A1:B10, table2 is in D1:E6, & table3 is in G1:I10. put :
=INDEX(E:E,MATCH(G2,D:D,0)) in I2
and drag downwards. ref : https://exceljet.net/index-and-match
Hope it helps. ( :

excel 2016 - delete rows based on multiple

I am trying to delete rows when the date in column B is not present exactly 4 times for a given filekey in column C. Sample data below:
A B C
Row Date Filekey
2 1/6/2014 1
3 1/6/2014 1
4 1/6/2014 1
5 1/6/2014 1
6 1/7/2014 1
7 1/7/2014 1
8 1/8/2014 1
9 1/9/2014 1
10 1/9/2014 1
11 1/9/2014 1
12 1/9/2014 1
13 1/9/2014 1
14 1/6/2014 2
15 1/6/2014 2
16 1/6/2014 2
17 1/6/2014 2
The result I am looking for:
Row Date Filekey
2 1/6/2014 1
3 1/6/2014 1
4 1/6/2014 1
5 1/6/2014 1
14 1/6/2014 2
15 1/6/2014 2
16 1/6/2014 2
17 1/6/2014 2
Please note that Row 6-7 were removed for only having 2 dates the same (too few), Row 8 for 1 date (too few), Rows 9-13 for 5 dates (too many)
Rows 14-17 were kept because:
there are exactly 4 rows with that date and it has a different filekey (column C) than rows 2-5 even though it shares those four dates.
Thanks for your help.
In cell D2 use this formula and copy down:
=COUNTIFS(B:B,B2,C:C,C2)
Then filter on column D for everything other than 4 and delete those rows, then remove the filter and you can delete the formulas in column D

Excel - How do I create a cumulative sum column within a group?

In Excel, I have an hours log that looks like this:
PersonID Hours JobCode
1 7 1
1 6 2
1 8 3
1 10 1
2 5 3
2 3 5
2 12 2
2 4 1
What I would like to do is create a column with a running total, but only within each PersonID so I want to create this:
PersonID Hours JobCode Total
1 7 1 7
1 6 2 13
1 8 3 21
1 10 1 31
2 5 3 5
2 3 5 8
2 12 2 20
2 4 1 24
Any ideas on how to do that?
In D2 and fill down:
=SUMIF(A$2:A2,A2,B$2:B2)
Assuming that your data starts in cell A1, this formula will accumulate the hours until it finds a change in person ID.
=IF(A2=A1,D1+B2,B2)
Put the formula in cell D2, and copy down for each row of your data.

Sum numbers if multiple criteria is met in other cells

I have an Excel spreadsheet with data laid out like so:
Column A Column B Column C Column D
Row 1 Sector Rail
Row 2 A B C
Row 3 Type 1 1 5 1
Row 4 Type 2 2 3 0
Row 5 Type 3 1 1 6
Row 6 Total 4 9 7
In row 1 you can see in column A I have sector, and in column B I have the type of sector, i.e. Rail. My spreadsheet has several occurrences of different data following this structure, like so:
Column A Column B Column C Column D
Row 1 Sector Rail
Row 2 A B C
Row 3 Type 1 1 5 1
Row 4 Type 2 2 3 0
Row 5 Type 3 1 1 6
Row 6 Total 4 9 7
Row 7
Row 8 Sector aerospace
Row 9 A B C
Row 10 Type 1 0 9 9
Row 11 Type 2 3 3 1
Row 12 Type 3 4 5 6
Row 13 Total 0 1 8
Row 14
Row 15 Sector Rail
Row 16 A B C
Row 17 Type 1 8 9 9
Row 18 Type 2 3 3 1
Row 19 Type 3 4 5 6
Row 20 Total 9 1 8
Note that there are two sets of data with the sector Rail and one with Aerospace in the middle.
Now I need a formula that will add the numbers from the total in column B row 6 and add the total number from column b row 20. But only for Rail.
So Column B row 1 has a sector Rail, but so does Column B row 14.
So I need one formula which will find both occurrences of the word Rail and then give me the total numbers of row 6 + row 20, which would be 1 + 8 = Total of 9
Can anyone please show me if this is possible?
Please try deleting Row2 and:
=SUMIF(B1:B98,"Rail",B2:B99)

Resources