Can i use TextSplit with Find formula? - excel

I am making a table up that will sum all matches of a company found within a specific time period. I need to also exclude certain months if they are inserted into a cell as mm/yy. Excluding one month is fine but when i type 10/22, 11/22, it will sum everthing. THe below code is what i am using with U$4 being the end of a month minus the tracking period which is 90 days. Note that the Raw Data that it is reading from only goes to end of November.
=IF([#[Company Name]]="","",SUM(IF(ISNUMBER(SEARCH([#[Company Name]],RawData[Description]))=TRUE,IF(RawData[Home]=XLOOKUP($D$1,HomeList[Home Code],HomeList[Home]),IF(RawData[Source]="Spend Money",IF(RawData[Date]<=U$4,IF(RawData[Date]>=U$4-[#[Tracking period (Days)]],1,0)))))))
With one date inserted which is correct:
28/Feb 31/Mar 30/Apr 31/May 30/Jun 31/Jul 31/Aug 30/Sep 31/Oct 30/Nov 31/Dec 31/Jan
Exclude Company Name Tracking period (Days) Month 1 Month 2 Month 3 Month 4 Month 5 Month 6 Month 7 Month 8 Month 9 Month 10 Month 11 Month 12
11/22 CLH 90 0 0 0 0 0 0 0 1 2 2 1 0
With multiple months inserted which is incorrect:
28/Feb 31/Mar 30/Apr 31/May 30/Jun 31/Jul 31/Aug 30/Sep 31/Oct 30/Nov 31/Dec 31/Jan
Exclude Company Name Tracking period (Days) Month 1 Month 2 Month 3 Month 4 Month 5 Month 6 Month 7 Month 8 Month 9 Month 10 Month 11 Month 12
10/22,11/22 CLH 90 0 0 0 0 0 0 0 2 3 8 6 5
Expected if multiple months as it has found one match for September so counts it
28/Feb 31/Mar 30/Apr 31/May 30/Jun 31/Jul 31/Aug 30/Sep 31/Oct 30/Nov 31/Dec 31/Jan
Exclude Company Name Tracking period (Days) Month 1 Month 2 Month 3 Month 4 Month 5 Month 6 Month 7 Month 8 Month 9 Month 10 Month 11 Month 12
10/22,11/22 CLH 90 0 0 0 0 0 0 0 1 1 1 0 0

Had to use MATCH with the TEXTSPLIT for it to work
=IF([#[Company Name]]="","",SUM(IF(ISNUMBER(SEARCH([#[Company Name]],RawData[Description]))=TRUE,IF(RawData[Home]=XLOOKUP($D$1,HomeList[Home Code],HomeList[Home]),IF(RawData[Source]="Spend Money",IF(RawData[Date]<=S$4,IF(RawData[Date]>=S$4-[#[Tracking period (Days)]],IF(ISNUMBER(MATCH(RawData[Find Date],TEXTSPLIT([#Exclude],","),)),0,1))))))))

Related

pandas dataframe columns for each month of year

I have a CSV file with employee information. There are multiple records for an employee describing his monthly information. I want to create a consolidated dataframe where there are columns for each month and the number of leave days availed for each month is stored in the appropriate column
Emp. Code Month Year leave Days
1 2-2022 10
2 3-2022 15
1 3-2022 20
2 2-2022 2
1 4-2022 3
1 5-2022 2
2 6-2022 4
expected output
empcode leavedays-Feb leavedays-march leavedays-april
1 10 15 3
2 2 15 nil

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 the number of instances a row changes from a specific number to another

Got a bit of a conundrum I've been wracking my brain on for far to long and was wondering if anyone could help.
I have a list of items in column A and columns labelled as weekly periods from B:DA
Item Code
Week 1
Week 2
Week 3
Week 4
Week 5
Week 6
Week 7
Week 8
Results
Item 1
1
1
0
1
0
0
1
0
3
Item 2
1
1
0
0
1
1
1
I need to count the number of times the weekly status goes from 1 to 0 but not from 0 to 1.
In the tabled example I would expect the results to be Item 1 = 3 and Item 2 = 1
Any help pointing me in the right direction would be much appreciated!
Use COUNTIFS():
=COUNTIFS(B2:CZ2,1,C2:DA2,0)
The offset ranges will allow the count of when the prior cell is 1 and the following is 0.

How to add days based on another date?

i want to add +2 days to column based on other column i use this table :
Company Type Joinning Date Starting day
1 1 19/01/2019
2 0 19/01/2019
3 0 19/01/2019
4 1 20/01/2019
5 0 20/01/2019
6 1 21/01/2019
i want to add +2 DAYS in column Starting day which is Joining day + 2 days if the company have type 1 how can i do it ?
What i've tried ?
pic
Desired Results
Company Type Joinning Date Starting day
1 1 19/01/2019 21/01/2019
2 0 19/01/2019
3 0 19/01/2019
4 1 20/01/2019 22/01/2019
5 0 20/01/2019
6 1 21/01/2019 23/01/2019
Just to show my comment of:
=IF(B2=1,C2+2,"")
Works. The output cell must be formatted in the desired method:

Returning total sum of value for each month. VBA

I need to produce a total value for each month of the year from a generated report. Data is split into colunms one with a value you the other with a date.
I need to return a total for each month.
Data is output as such:
100 21/01/2019
200 21/06/2019
150 01/01/2019
300 14/09/2019
8 08/05/2019
I need it to return as
1 2 3 4 5 6 7 8 9 10 11 12
250 0 0 0 8 200 0 0 300 0 0 0
With a further column for the following year. The original data and dates can be removed as this can be reproduced when running the next report.
You could try the below:
Add a helper column next to you date to get the month of the date:
=MONTH(B3)
and use:
=SUMPRODUCT(($C$3:$C$7=F2)*($A$3:$A$7))
Results:

Resources