Function in Excel to average numbers under weeks column and show them in month - excel

In the attached image, I would like to sum the average of every week and show it in months. For example,
weeks no: 1 2 3 4 5 6 7 8 9 10
Numbers : 12 15 16 5 8 9 45 78 8 96
Show the average of the week in month.
Thanks for help.
Cheers
Hosein

The following formula will give you the average for each month for a given row:
=AVERAGEIFS($A$4:$V$4,$A$1:$V$1,">="&A9,$A$1:$V$1,"<="&EOMONTH(A9,0))
Here's the final result:
I'm hoping it's a good starting point.

Related

Calculate production capacity per product/day up to goal

I have the following data.
Available resources data per day:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
2
resources
day
3
1
2
3
4
5
6
7
8
9
10
11
12
4
empl.1
8
8
4
2
2
4
4
8
8
5
empl.2
8
4
4
8
4
8
6
empl.3
And different products and it's production per hour (per employee) and the required quantity per part:
P
Q
R
S
2
product
production/hour
required qty
3
4
prod.1
1
60
5
prod.2
1
6
6
prod.3
2
4
From this data I want to calculate the number of products that can be produced per day based on the available employees for the day and the production capacity for that product up until the goal is reached for that product.
edit: calculation from original post was calculating to hours spent per product per day only, not to qty of products produced; also the MOD-part gave wrong calculation results if the daily produced qty exceeds the goal
I use the following formula to calculate the above (used in C11 and dragged to the right):
=LET(
prod,BYROW($B11:B13,LAMBDA(r,SUM(r))),
reached,--(prod<$S$4:$S$6),
dayprod,IFERROR(SUM(C4:C6)/SUM(reached*$R$4:$R$6),0)*reached*$R$4:$R$6,
IF(prod+dayprod>$S$4:$S$6,dayprod-((prod+dayprod)-$S$4:$S$6),dayprod))
This results in the following:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
9
product
day
10
1
2
3
4
5
6
7
8
9
10
11
12
11
prod.1
2
8
4
6
2
8
4
0
8
12
6
0
12
prod.2
2
4
0
0
0
0
0
0
0
0
0
0
13
prod.3
4
0
0
0
0
0
0
0
0
0
0
0
This formula sums the hours from the employees available that day and divides their hours over the products that did not reach the goal yet.
If the goal is reached the available hours are divided over the remaining products to produce.
Screenshot of the data + current result:
Now the problem I'm having is the following:
If the goal is reached for a product somewhere halfway the day the dayprod-((prod+dayprod)-$S$4:$S$6)-part of the function calculates the remaining hours of production for that product for that day, but the available hours from the employees are divided over each product that needs production still, but let's take the following example:
prod.1, day 2: value 8
prod.2, day 2: value 4
The 8 for prod.1 is calculated based on both prod.1 & prod.2 in need for production still and both take 1 hour per person to produce one.
Having 16 hours available that day that means a capacity of 8 for each.
But the challenge lies in the goal being reached halfway the day.
In fact the first 4 hours are used by both employees to produce 4 of each product.
The last 4 hours both employees can focus on prod.1 resulting in not qty 4 of production for the last 4 hours, but 4 + 4 which results in a total of 12 being produced for prod.1, not 8 like now calculated.
How can I get the formula to add the remaining time to the remaining products?
Original post, prior to edit, containing error (not calculating to number of products, but to number of hours spent per product per day only)
I use the following formula to calculate the above (used in C11 and dragged to the right):
=LET(
prod,BYROW($B11:B13,LAMBDA(r,SUM(r))),
reached,--(prod<$S$4:$S$6),
dayprod,IFERROR(SUM(C4:C6)/SUM(reached*$R$4:$R$6),0)*reached*$R$4:$R$6,
IF(prod+dayprod>$S$4:$S$6,dayprod-MOD(prod+dayprod,$S$4:$S$6),dayprod))
This results in the following:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
9
product
day
10
1
2
3
4
5
6
7
8
9
10
11
12
11
prod.1
2
8
4
6
2
8
4
0
8
12
6
0
12
prod.2
2
4
0
0
0
0
0
0
0
0
0
0
13
prod.3
4
0
0
0
0
0
0
0
0
0
0
0
This formula sums the hours from the employees available that day and divides their hours over the products that did not reach the goal yet.
If the goal is reached the available hours are divided over the remaining products to produce.
Screenshot of the data + current result:
Now the problem I'm having is the following:
If the goal is reached for a product somewhere halfway the day the MOD-part of the function calculates the remaining qty for that product for that day, but the available hours from the employees are divided over each product that needs production still, but let's take the following example:
prod.1, day 2: value 8
prod.2, day 2: value 4
The 8 for prod.1 is calculated based on both prod.1 & prod.2 in need for production still and both take 1 hour per person to produce one.
Having 16 hours available that day that means a capacity of 8 for each.
But the challenge lies in the goal being reached halfway the day.
In fact the first 4 hours are used by both employees to produce 4 of each product.
The last 4 hours both employees can focus on prod.1 resulting in a total of 12 being produced for prod.1, not 8.
I kind of broke my head on getting this far, but from here I could use some help.
How can I get the MOD part of the formula to add the remaining time to the remaining products?
I was able to find a solution to my problem.
I had to use the result from the formula in place and check if the sum up to the current day (including that day's production) exceeds the goal. If so I needed to get the time difference between the day's production and that day's production needed to get to the goal. The difference is the time of production to be added to the remaining part(s) for that day that did not reach the goal yet, also not when adding the day's production.
This results in the following formula in C11 dragged to the right:
=LET(
prod,BYROW($B11:B13,LAMBDA(r,SUM(r))),
prodhour,$R$4:$R$6,
goal,$S$4:$S$6,
reached,--(prod<goal),
dayprod,(IFERROR(SUM(C$4:C$6)/SUM(reached*prodhour),0)*reached*prodhour)*prodhour,
preres,IF(prod+dayprod>goal,dayprod-((prod+dayprod)-goal),dayprod),
timecorr,(dayprod*(dayprod<>preres)-preres*(dayprod<>preres))/prodhour,
reachedcorr,reached*(timecorr=0),
dayprodcorr,(IFERROR(SUM(timecorr)/SUM(reachedcorr*prodhour),0)*reachedcorr*prodhour)*prodhour,
IF(prod+dayprod>=goal,dayprod-((prod+dayprod)-goal),dayprod+dayprodcorr))
Where preres is the previous result (from where I got stuck in the opening post).
And the corr parts are taking care of the correction if goal is reached for a product and there was still production time remaining.

Counting total number in Excel with a specific value in cells and a single column

Hope someone can help me out with what is probably quite a simple thing in Excel but I just can't seem to be able to work it out. I have a table of numbers which correspond to colour codes:
A
B
C
D
E
F
2
2
2
2
2
24
36
36
2
2
2
24
2
2
2
2
2
2
36
2
36
2
2
24
2
2
36
2
2
2
2
36
2
2
2
24
2
2
2
2
36
2
What I would like to able to have is some way of having a total based on the criteria:
Count the total number of times '36' appears in the table only if the row has '24' in column F
I've tried using COUNTIF and COUNTIFS but that only works for matching sized columns of data.
Any help would be really appreciated.
Use SUMPRODUCT:
=SUMPRODUCT((A1:E7=36)*(F1:F7=24))

How to group by an Attribute and calculate time between consecutive tickets for that Attribute

So, I am working with a Dataframe where there are around 20 columns, but only two columns are really of importance.
Index
ID
Date
1
01-40-50
2021-12-01 16:54:00
2
01-10
2021-10-11 13:28:00
3
03-48-58
2021-11-05 16:54:00
4
01-40-50
2021-12-06 19:34:00
5
03-48-58
2021-12-09 12:14:00
6
01-10
2021-08-06 19:34:00
7
03-48-58
2021-10-01 11:44:00
There are 90 different ID's and a few thousand rows in total. What I want to do is:
Group the entries by the ID's
Order those ID rows by the Date
Then calculate the difference between one timestamp to another
And create a column that has those entries (to then visualize it for the 90 different ID's)
While I thought it would be an easy thing to use the function groupby, I am having quite a bit of trouble. Would appreciate any input as to how to start this! Thank you!
You can do it this way:
>>> df.groupby("ID")["Date"].apply(lambda x: x.sort_values().diff())
ID Index
01-10 6 NaT
2 65 days 17:54:00
01-40-50 1 NaT
4 5 days 02:40:00
03-48-58 7 NaT
3 35 days 05:10:00
5 33 days 19:20:00

Calculate sum for entire sheet based on hours

I have a spreadsheet that has various weekly hours against a fixed number. For example
Name Weekly Hours Week 1 Week 2 Week 3
Jon 40 44 36 40
Shaun 40 40 36 44
Dawn 20 25 10 16
Is there a way where I can convert the weekly hours so that they have the sum of Weekly Hours - Week
Example for Jon
-4, 4, 0
Not sure how to do this and wondered if there was a global setting/sum?

Table transformation in Excel

I have a spreadsheet with data in following format:
CarID Day DistanceTraveled
Ford1 1 10
Ford1 2 12
Nissan1 1 13
Ford1 3 41
Nissan1 2 20
Nissan1 3 10
...
And so on. There are a few hundreds of records in format like this, with a few dozens of cars.
I have to transform it into a following format:
Day Ford1 Nissan1
1 10 13
2 12 20
3 41 10
Is it any fast and automatic way to achieve it in Excel?
Just for the sake of an answer:

Resources