Please provide an array formula. Can you help to reset running totals when MOQ is reached?. Here MOQ=15. When running total becomes equal to or greater than 15 it should restart.
Date
Value
Desired
12/2022
6
6
01/2023
5
11
02/2023
4
15
03/2023
3
3
04/2023
9
12
05/2023
2
14
06/2023
6
20
07/2023
1
1
08/2023
6
7
09/2023
1
8
10/2023
8
16
11/2023
9
9
12/2023
3
12
all we need is a unique common ID for grouping the sum. we start with months to fall from whatever date to months 3, 7 and 11:
=ARRAYFORMULA(IFNA(VLOOKUP(MONTH(A2:A), {3;7;11}, 1, 1), 11))
next, we can use years to differentiate between 11/2022 and 11/2023 so we take whatever date and convert it into first day of given month and then offset the year by 58 days:
=ARRAYFORMULA(YEAR(EOMONTH(A2:A, -1)+1-58))
we combine it to get a unique ID per MOQ:
=ARRAYFORMULA(IFERROR(IFNA(VLOOKUP(MONTH(A2:A), {3;7;11}, 1, 1), 11)&
" "&YEAR(EOMONTH(A2:A, -1)+1-58)))
then we just use standard running total fx:
=ARRAYFORMULA(IF(A2:A="",,
MMULT(--TRANSPOSE(IF((TRANSPOSE(ROW(A2:A))>=ROW(A2:A))*(
IFERROR(IFNA(VLOOKUP(MONTH(A2:A), {3;7;11}, 1, 1), 11)&"×"&
YEAR(EOMONTH(A2:A, -1)+1-58))=TRANSPOSE(
IFERROR(IFNA(VLOOKUP(MONTH(A2:A), {3;7;11}, 1, 1), 11)&"×"&
YEAR(EOMONTH(A2:A, -1)+1-58)))), B2:B, 0)), ROW(A2:A)^0)))
update:
=ARRAYFORMULA(IF(A2:A="",, MMULT(--TRANSPOSE(IF((TRANSPOSE(ROW(B2:B))>=ROW(B2:B))*(
ARRAY_CONSTRAIN({0; IF(TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15)>
MAX(TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15))-1,
MAX(TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15))-1,
TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15))}, ROWS(B2:B), 1)=TRANSPOSE(
ARRAY_CONSTRAIN({0; IF(TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15)>
MAX(TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15))-1,
MAX(TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15))-1,
TRUNC(SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)/15))}, ROWS(B2:B), 1))), B2:B, 0)),
ROW(B2:B)^0)))
Use the new SCAN function
=SCAN(0,B2:B, LAMBDA(a,c, IF(c="",,IF(a>=15,c,a+c))))
What we did is: return the running total of Values if less than or equal 15, else rest.
Explation
SCAN Takes initial_value we set it to 0 and array_or_range we name it c "Current value" for short, and the accumulator in lambda a you can name them any thing.
IF the accumulator a is greater or equal 15 >= 15 then reset by returning the Current value of array_or_range c, if not add the current value of array_or_range c to the accumulator a.
Used formulas help
SCAN - LAMBDA - IF
Related
I found this partial solution to my problem:
Google Sheets auto increment column A if column B is not empty
With this formula:
=ARRAYFORMULA(IFERROR(MATCH($B$2:$B&ROW($B$2:$B),FILTER($B$2:$B&ROW($B$2:$B),$B$2:$B<>""),0)))
What I need is the same but instead of continuous numbers I'd need it to restart incrementing from 1 at each new category string on an adjacent column (column A in example below, categories strings are A, B, C, D etc.).
For example:
Problem with formula in C12 and C15 (added numbers 1 and 2)
Needed result in column D, as with D11 and D19 restarts incrementing from 1 at new category string)
1
needed result
2
A
1
1
1
3
A
4
A
5
A
1
2
2
6
A
7
A
8
A
9
A
1
3
3
10
A
11
B
1
4
1
12
B
1
13
B
14
C
1
5
2
15
C
2
16
C
17
C
1
6
3
18
C
19
D
1
7
1
20
D
21
D
22
D
1
8
2
23
D
24
D
1
9
3
25
D
26
D
27
D
1
10
4
28
D
29
D
try:
=INDEX(IF(B2:B="",,COUNTIFS(A2:A&B2:B, A2:A&B2:B, ROW(A2:A), "<="&ROW(A2:A))))
or:
=INDEX(IF(B2:B="",,COUNTIFS(A2:A&IF(B2:B<>"", 1, ), A2:A&IF(B2:B<>"", 1, ), ROW(A2:A), "<="&ROW(A2:A))))
Here's another similar solution.
=ArrayFormula(if(B2:B="",,countifs(A2:A,A2:A,B2:B,"<>",row(A2:A),"<="&row(A2:A))))
I am trying to calculate points in a Formula 1 racing league. I'm having trouble with a bonus 15 points if a constructor qualifies 1st and finishes the race 1st. The issue is there could be two different drivers who do this. For example. As you can see, HAM qualified 1st and ROS finished 1st in the race. Because they both drive for Mercedes, 15 points need to be awarded to Mercedes. The data can't be moved around as it's imported using an API (not in the example) but a copy of the layout can be found here
Qualifying Race Driver Team
14 1 ROS mercedes
1 15 HAM mercedes
3 3 VET ferrari
8 4 RIC red_bull
6 5 MAS williams
19 6 GRO haas
10 7 HUL force_india
16 8 BOT williams
7 9 SAI toro_rosso
5 10 VES toro_rosso
13 11 PAL renault
Put this in I2 and copy down. See if that is how you want it:
=IF(AND(VLOOKUP(1, $A$2:$H$12, 8, FALSE)=VLOOKUP(1, $B$2:$H$12, 7, FALSE), VLOOKUP(1, $B$2:$H$12, 7, FALSE)=H2, MATCH(H2, H:H, 0)=ROW(H2)), 15, 0)
I wish to make a formula to sum up the value with 2 criteria, example show as below:-
A B C D E
1 1-Apr 2-Apr 3-Apr 4-Apr
2 aa 1 4 7 10
3 bb 2 5 8 11
4 cc 3 6 9 12
5
6 Criteria 1 bb
7 Range start 2-Apr-16
8 Range End 4-Apr-16
9 Total sum #VALUE!
tried formula
1 SUMIF(A2:A4,C6,INDEX(B2:E4,0,MATCH(C7,B1:E1,0)))
* Only return 1 cell value
2 SUMIF(A2:A4,C6,INDEX(B2:E4,0,MATCH(">="&C7,B1:E1,0)))
* Showed N/A error
3 SUMIFS(B2:E4,A2:A4,C6,B1:E1,">="&C7,B1:E1,"<="&C8)
* Showed #Value error
Hereby I attached a link of picture for better understanding :
Can anyone help me on the formula?
I figured out the solution with step evaluation:
=SUMIF(B1:F1,">="&C7,INDEX(B2:F4,MATCH(C6,A2:A4,0),0)) -
SUMIF(B1:F1,">"&C8,INDEX(B2:F4,MATCH(C6,A2:A4,0),0))
I have written this formula below. I do not know the correct part of this formula that will add the numbers I have in Column AB2:AB552. As it is, this formula is counting the number of cells in that range that has numbers in it, but I need it to total those numbers as my final result. Any help would be great.
=COUNTIFS(Cases!B2:B552,"1",Cases!G2:G552,"c*",Cases!X2:X552,"No",**Cases!AB2:AB552,">0"**)
Assuming you don't actually need the intermediate counts, the sumifs function should give you the final result:
=SUMIFS(Cases!AB2:AB552,Cases!B2:B552,1,Cases!G2:G552,"c",Cases!X2:X552,"No",Cases!AB2:AB552,">0")
Testing this with some limited data:
Row B G X AB
2 2 a No 10
3 1 c No 24
4 2 c No 4
5 1 c No 0
6 1 a Yes 9
7 2 c No 12
8 2 c No 6
9 2 b No 0
10 1 b No 0
11 1 a No 10
12 2 c No 6
13 1 c No 20
14 1 c No 4
15 1 b Yes 22
16 1 b Yes 22
the formula above returned 48, the sum of AB3, AB13, and AB14, which were the only rows matching all 4 criteria
I want to schedule Jenkins to run a certain job at 8:00 am every Monday, Wednesday Thursday and Friday and 8:00 am every other Tuesday.
Right now, the best I can think of is:
# 8am every Monday, Wednesday, Thursday, and Friday:
0 8 * * 1,3-5
# 8am on specific desired Tuesdays, one line per month:
0 8 13,27 3 2
0 8 10,24 4 2
0 8 8,22 5 2
0 8 5,19 6 2
0 8 3,17,31 7 2
0 8 14,28 8 2
0 8 11,25 9 2
0 8 9,23 10 2
0 8 6,20 11 2
0 8 4,18 12 2
which is is fine (if ugly) for the remainder of 2012, but it almost certainly won't do what I want in 2013.
Is there a more concise way to do this, or one that's year-independant?
This is something that comes up quite often, see e.g. this document, this forum thread or this stackoverflow question.
The answer is basically no. What I would do in your situtation is to run the job every Tuesday and have the first build step check whether to actually run by e.g. checking whether a file exists and only running if it doesn't. If it exists, it would be deleted so that the job can run the next time this check occurs. You would of course also have to check whether it's Tuesday.
I got you fam: crontab.guru
10 22 1-7,14-21,28-31 * 6
If you abandon every other Tuesday, and can be satisfied with the first and third Tuesdays a month, the following should work:
0 9 1-7 * 2
0 9 15-21 * 2
You're running every day from 1-7, but only on Tuesday, and every day from 15-21, again only on Tuesday. A Tuesday will occur only once in each of those intervals.
Yes, it's not strictly every other week, as a 5-Tuesday month will throw off your cadence, but here you have a predictable job schedule that doesn't need to be adjusted in Jenkins as time goes on.
I use Excel to generate the cron expressions. The following formulas generate every other Monday at 8:00 AM starting from Oct 22.
A B C D
1 41204 =MONTH(A1) =DAY(A1) =CONCATENATE("0 8 ", C1, " ", B1, " 1")
2 =A1+14 =MONTH(A2) =DAY(A2) =CONCATENATE("0 8 ", C2, " ", B2, " 1")
This generates
A B C D
1 22-Oct 10 22 0 8 22 10 1
2 5-Nov 11 5 0 8 5 11 1
Just auto fill Row 2 to get additional days. I'm not sure how many separate expressions you can give to Jenkins. I know it works with 26 expressions.