Google Sheets Divide value if other column not empty - excel
I have a sheet with the following values in minutes to keep track of how long it takes for x task:
+---------+----------+----------+
| A | B | C |
+---------+----------+----------+
| Task | Person 1 | Person 2 |
| Task #1 | 10 | 20 |
| Task #2 | 20 | 0 |
| Task #3 | 0 | 30 |
+---------+----------+----------+
I want to get total of hours for every task but if a task has time for Person 1 and Person 2, I want the average of the time taken for the task.
What I've had in mind previously is:
=(SUM(Tasks!$B$2:$B) + SUM(Tasks!$C$2:$C)) / 2
I thought this would work but then I realized it won't because some tasks are only handled by Person 1.
The total of the previous formula would give me 40, but what I'm expecting as a value should be 65, based on the following calculation:
(10 + 20) / 2 + 20 + 30
=SUMPRODUCT((B2:B4+C2:C4)/((B2:B4>0)+(C2:C4>0)))
Use this array formula:
=SUM(IF((B2:B4>0)*(C2:C4>0),(B2:B4+C2:C4)/2,B2:B4+C2:C4))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
Related
Counting 15's in Cribbage Hand
Background This is a followup question to my previous finding a straight in a cribbage hand question and Counting Pairs in Cribbage Hand Objective Count the number of ways cards can be combined to a total of 15, then score 2 points for each pair. Ace worth 1, and J,Q,K are worth 10. What I have Tried So my first poke at a solution required 26 different formulas. Basically I checked each possible way to combine cards to see if the total was 15. 1 way to add 5 cards, 5 ways to add 4 cards, 10 ways to add 3 cards, and 10 ways to add 2 cards. I thought I had this licked until I realized I was only looking at combinations, I had not considered the fact that I had to cap the value of cards 11, 12, and 13 to 10. I initially tried an array formula something along the lines of: MIN(MOD(B1:F1-1,13)+1,10) But the problem with this is that MIN takes the minimum value of all results not the individual results compared to 10. I then tried it with an IF function, which worked, but involved the use of CSE formula even wehen being used with SUMPRODUCT which is something I try to avoid when I can IF(MOD(B1:F1-1,13)+1<11,MOD(B1:F1-1,13)+1,10) Then I stumble on an answer to a question in code golf which I modified to lead me to this formula, which I kind of like for some strange reason, but its a bit long in repetitive use: --MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2) My current working formulas are: 5 card check =(SUMPRODUCT(--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2))=15)*2 4 card checks =(SUM(AGGREGATE(15,6,--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2),{1,2,3,4}))=15)*2 =(SUM(AGGREGATE(15,6,--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2),{1,2,3,5}))=15)*2 =(SUM(AGGREGATE(15,6,--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2),{1,2,4,5}))=15)*2 =(SUM(AGGREGATE(15,6,--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2),{1,3,4,5}))=15)*2 =(SUM(AGGREGATE(15,6,--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2),{2,3,4,5}))=15)*2 3 card checks same as 4 card checks using all combinations for 3 cards in the {1,2,3}. There are 10 different combinations, so 10 different formulas. The 2 card check was based on the solution by Tom in Counting Pairs in Cribbage Hand and all two cards are checked with a single formula. (yes it is CSE) 2 card check {=SUM(--(--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2)+TRANSPOSE(--MID("01020304050607080910101010",1+(MOD(B1:F1-1,13)*2),2))=15))} Question Can the 3 and 4 card combination sum check be brought into a single formula similar to the 2 card check? Is there a better way to convert cards 11,12,13 to a value of 10? Sample Data | B | C | D | E | F | POINTS +----+----+----+----+----+ | 1 | 2 | 3 | 17 | 31 | <= 2 (all 5 add to 15) | 1 | 2 | 3 | 17 | 32 | <= 2 (Last 4 add to 15) | 11 | 18 | 31 | 44 | 5 | <= 16 ( 4x(J+5), 4X(5+5+5) ) | 6 | 7 | 8 | 9 | 52 | <= 4 (6+9, 7+8) | 1 | 3 | 7 | 8 | 52 | <= 2 (7+8) | 2 | 3 | 7 | 9 | 52 | <= 2 (2+3+K) | 2 | 4 | 6 | 23 | 52 | <= 0 (nothing add to 15) Excel Version Excel 2013
For 5: =(SUMPRODUCT(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10))=15)*2 For 4: =SUMPRODUCT(--(MMULT(INDEX(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)*ROW($1:$10)^0,ROW($1:$5),{1,2,3,4;1,2,3,5;1,2,4,5;1,3,4,5;2,3,4,5}),ROW($1:$4)^0)=15))*2 For 3 =SUMPRODUCT(--(MMULT(INDEX(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)*ROW($1:$10)^0,ROW($1:$10),{1,2,3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2,3,4;2,3,5;2,4,5;3,4,5}),ROW($1:$3)^0)=15))*2 For 2: SUMPRODUCT(--((CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10))+(TRANSPOSE(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)))=15)) All together: =(SUMPRODUCT(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10))=15)*2+ SUMPRODUCT(--(MMULT(INDEX(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)*ROW($1:$10)^0,ROW($1:$5),{1,2,3,4;1,2,3,5;1,2,4,5;1,3,4,5;2,3,4,5}),ROW($1:$4)^0)=15))*2+ SUMPRODUCT(--(MMULT(INDEX(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)*ROW($1:$10)^0,ROW($1:$10),{1,2,3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2,3,4;2,3,5;2,4,5;3,4,5}),ROW($1:$3)^0)=15))*2+ SUMPRODUCT(--((CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10))+(TRANSPOSE(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)))=15)) For older versions we need to "trick" INDEX into accepting the arrays as Row and Column References: We do that by using N(IF({1},[thearray])) =(SUMPRODUCT(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10))=15)*2+ SUMPRODUCT(--(MMULT(INDEX(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)*ROW($1:$10)^0,N(IF({1},ROW($1:$5))),N(IF({1},{1,2,3,4;1,2,3,5;1,2,4,5;1,3,4,5;2,3,4,5}))),ROW($1:$4)^0)=15))*2+ SUMPRODUCT(--(MMULT(INDEX(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)*ROW($1:$10)^0,N(IF({1},ROW($1:$10))),N(IF({1},{1,2,3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2,3,4;2,3,5;2,4,5;3,4,5}))),ROW($1:$3)^0)=15))*2+ SUMPRODUCT(--((CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10))+(TRANSPOSE(CHOOSE(MOD(A1:E1-1,13)+1,1,2,3,4,5,6,7,8,9,10,10,10,10)))=15)) This is a CSE That must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
Grouping excel files by Week Number
I am trying to work on a Excel that has a giant amount of data with dates, to simplify I want it to group the different numbers into weeks, allow me to explain: The actual rows are like: 29-11-2018 | 49 | 1 | 4 |7 | 2 30-11-2018 | 49 | 4 | 0 |2 | 1 Where "49" is the week number from the date. I'm trying to make Excel put together those lines by week and add the other lines, like this: 49 | 5 | 4 | 9 | 3 And this for all the weeks, so I can know the exact number of data for every week. Is there a way of doing this? Thanks! Regards,
Assuming your data is located at A2:F3.. H2 ---> =B2 put I2 ---> =IF($B1<>$B2,C2,I1+C2) and drag to L2, then N2 ---> =IF($B3<>$B2,H2,"") and drag to R2. Select H2:R2 and drag to the end.. you'll see your intended result in column N to R.
Excel Summing Sequences?
I'm trying to do sequential summing on a spreadsheet. The first rows are data by date, and I want do sums by the week. but Excel's autopopulate keeps screwing it up and I don't know how to fix that. Date A ---- 1 | 5 2 | 5 3 | 5 4 | 5 5 | 5 6 | 5 7 | 5 8 | 5 9 | 5 10 | 5 11 | 5 12 | 5 13 | 5 14 | 5 so what I want in another area Week Total 1 | =sum(A1:A7) 2 | =sum(A8:A14) 3 | =sum(A15:A21) 4 | continue like this for 52 weeks but what excel keeps giving me with it's auto populating is Week Total 1 | =sum(A1:A7) #The first iteration 2 | =sum(A2:A8) #auto generated 3 | =sum(A3:A9) #auto generated How can I get excel to give me the results I want here? I've been searching on summing for a while and can't seem to even phrase my question right.
=sum(indirect("A"&(row()*7-6)&":A"&(row()*7))) pasted in row 1 and below should work at least in sheets, it does. (and excel docs say indirect works)
3 condition IF formula Excel
I'm looking to create an excel formula with 3 conditions. Here's what I'm looking for: D11 has a number (it is number of working hours). If the number is less than 4 (i.e. <=4), then I want it to show a value in cell B5, If the number is between 4 and 8 (i.e. >4 and <=8), then I want it to show a value in cell B6. If the number is over 8, then I want it to show a value in cell B7. The cells in B5, B6 and B7 contain the relevant renimeration for 4-hours shift, 8-hours shift and for overtime. This is what I have made: IF(D11<4,"$B$5",IF(AND(D11>=4,E9<=8),"$B$6","$B$7")). The Formula always gives a message : "The formula you typed conains an error: - for information about fixing....;-to get assistance.....; - if you are not trying....... Please advise!
I have tested and the follwoing is working for me: =IF(B2<4,$E$2,IF(AND(B2>=4,B2<=8),$F$2,$G$2)) Here is the example of the data I was working with (replacing FORMULA with the above): +-----+----------+----------+------------+-------------+-------------+-----------+--------+ | | A | B | C | D | E | F | G | +-----+-----------------------------------------------------------------------------------+ | 1 | name | Overtime | Due | | | | | +-----+-----------------------------------------------------------------------------------+ | 2 | bob | 4 | FORMULA | | 10 | 20 | 30 | +-----+-----------------------------------------------------------------------------------+ Effectively if B2 is 4 then C2 should show 10.
Thank all of you. The problem was with the local settings that expect ; rather than , in Excel formulas. Still I have problem with the formula, because I foud out that I should include one more condition: the case when the person is not working D11=0, because then he/she should receieve 0 or in the cell should be written a text "free day".
Retrieving Max in range of one column dictated by another column
My set up is fairly simple. I have paired data where one column is time and the next is a value corresponding to that time point. This recurs for many trials with each trial having a different number of time points Time Freq 0.216 0.000 0.423 4.835 0.620 5.067 0.784 6.108 0.971 5.355 1.156 5.395 1.311 6.470 1.433 8.170 1.575 7.034 1.752 5.673 1.925 5.758 2.077 6.602 2.180 9.675 2.363 5.477 2.487 8.022 2.616 7.795 2.773 6.344 2.915 7.050 3.074 6.283 3.208 7.495 3.395 5.344 3.535 7.111 3.682 6.839 3.830 6.730 4.023 5.185 This is an example from a table. What I want to do is to create a formulate that will pull the Max Frequency when Time is greater that 1 and less than 3. I know this can be done by manually selecting the range, but I have many different ranges that I want to find the max freq for would like to be able to just input the column.
You can reference upper and lower bounds for the time variable like this: +---+----+----+-------+ | | D | E | F | +---+----+----+-------+ | 1 | LB | UB |MaxFreq| | 2 | 1 | 3 | 9.675 | | 3 | 0 | 1 | 6.108 | | 4 | 1 | 2 | 8.17 | | 5 | 2 | 3 | 9.675 | +---+----+----+-------+ F2: =MAX(IF(($A$1:$A$26>$D2)*($A$1:$A$26<$E2),$B$1:$B$26)) F2 is an array formula--confirm the entry with the combination Ctrl+Shift+Enter (not just Enter). It can be copied down as far as needed.