excel networkdays sum over range - excel-formula

Goal:I'm looking to calculate the sum of the elapsed work days between two columns on sheet1 for use in a formula that returns average time elapsed on sheet2.
Rule 1: I can't add columns to sheet1, so I'd ideally like to do this entirely in a formula on sheet2.
So far, I know that you can use =NETWORKDAYS(Cell1,Cell2) to do this on an individual basis, but that voids rule 1 where I can't add columns. I also know that I can use =SUM(NETWORKDAYS(O5+1,P5),NETWORKDAYS(O6+1,P6)), but I'd rather define a range instead of each cell.
Ideally, I'd like to take the result of the sum of networking days and divide that by a separate variable with the same range to get time per variable in that range. Any help on making this possible?

Assuming the Sheet2!R4 cell is empty.. do :
In Sheet2!O5 , put =Sheet1!O5 . Then in Sheet2!P5 , put =Sheet1!P5 . drag downwards
to get all Sheet1 dates.
Then in Sheet2!Q5 put =NETWORKDAYS(O5+1,P5) . and in Sheet2!R5 put =R4+Q5 . And drag both downwards.. the last column R value is equivalent to the
=SUM(NETWORKDAYS(O5+1,P5),NETWORKDAYS(O6+1,P6))
you've mentioned. Hope it helps.

Related

Excel formula to sum as long as

I'm trying to find a formula to calculate the balance of a column until a negative value is found. After the negative value is found, the balance must be calculated again until the next negative value. Basically tracking what you spent, except it only shows a value when you sold something. Anybody have an idea if this is possible to do in MS excel? Thanks!
OK. Now I get your question. I think the following will do the trick. The results exactly match your example.
// In these cells only
F2: =MAX(0,B2*C2)
G2: =MAX(0,B2)+MIN(0,B2)
// In these cells, then copy down
E3: =IF(B3<0,D3-(F2-F3),"")
F3: =F2+MAX(0,B3*C3)+IF(G2=0,0,MIN(0,B3*F2/G2))
G3: =G2+MAX(0,B3)+MIN(0,B3)
I would note a couple of things about this:
1) You might consider changing the names of your columns to trans, quan, $ per, $ ttl, $ gp, and name the 2 columns I am adding $ inv and inv.
2) This is using the average cost of inventory, recalculated with each transaction, not LIFO or FIFO.
3) If entries get out of order such that quan goes negative, I think this solution will fail. In any case, that might be an error you'd want to notice.
4) FYI, the "IF(G2=0" part of F3 is only there to avoid a divide by 0 error when G2 (inventory) is 0. I could have done this other ways, of course. It works.
5) I've left E2 blank on the assumption that you can't sell as you've not bought.
One way would be to add 2 additional columns, which could be hidden or on another sheet, then (here assuming adding columns F2 and G2 added at the right):
In Cell E2: =IF(B2<0,G2,"")
In Cell F2: =B2*C2
In Cell G2: =SUM(F$2:F2)
Copy these down and, assuming I understand your question correctly, you'll get the results you desire.
The biggest problem you've got with this is working out the ranges to check for the balance calculation. This won't work if the next row in your table is a 'sell' while you've still got one 'apple' left from the previous purchase. If you want to do anything more convoluted you should use VBA.
Others will probably have an easier way to work out the ranges; I did it in a rather convoluted way and don't have time to optimise them.
In column F there's an array formula to calculate the last row in the range of 'buys' relevant to that 'sell'.
=IF($B2>=0,"",LARGE(IF($B$2:$B2>0,ROW($A$2:$A2)),1))
In column G there's a normal formula to capture the row number of the first row in the range.
=IF(ROW()=2,ROW(),IF(B2>0,IF(B1<0,ROW(),""),""))
In column H, convert this to be stored in the relevant 'sell' row using an array formula:
=IF($B2>=0,"",LARGE(IF($G$2:$G2>0,$G$2:G2),1))
In column E, balance, use these calculated row range references in an INDIRECT statement to calculate the balance.
=IF(B2>0,"",(C2*-(B2))-(-(B2)*(SUMPRODUCT(INDIRECT("B"&H2&":B"&F2),INDIRECT("C"&H2&":C"&F2)/SUM(INDIRECT("B"&H2&":B"&F2))))))
Note that INDIRECT uses a string to reference cells and ranges and if you move cells or ranges you will have to manually change the INDIRECT string to reference the correct cells.
Responding to #carol, and looking at the Q&A again, specifically where you say " although the problems comes up after because it needs to ignore the balances that came before José and start with the new ones that follow up," I realize that you may be looking to instead display the balance of all sales receipts and purchases since the last sale. If so:
In Cell G2: =F2
Do not copy down the above. Do copy down those below.
In Cell E2: =IF(B2<0,G2,"")
In Cell F2: =B2*C2
In Cell G3: =IF(B2<0,F3,F3+G2)

Counting the Amount with Multiplication Condition

I have an Excel List That Looks Like This:
And i need to Count the Amount of Rows that have the Value Finished in Row C. But if T Value in Column B Contains a Semikolon it hase to Count double, if it Contains 2 Semikolons it hase to count 3 and so on...
Her is a Picture to show how the Counting should work.
I will not be able to Add Another Column to the Sheet, so i'm Locking for a Matrix Fomula or something like this.
Till now i tried it with the Countif and Countifs Formula but that didn't work.
Can someone give me a hint how to do thsi or waht Fomula would be the best to use?
For your "Finished" total, use this formula (adjust ranges as necessary to fit your actual data):
=SUMPRODUCT((LEN($B$5:$B$28)-LEN(SUBSTITUTE($B$5:$B$28,";",""))+1)*($C$5:$C$28="Finished"))
For your "Pending" total, if it needs the same treatment, use this formula:
=SUMPRODUCT((LEN($B$5:$B$28)-LEN(SUBSTITUTE($B$5:$B$28,";",""))+1)*($C$5:$C$28="Pending"))
Are you allowed to use/create a new worksheet (other than the one containing the data)? If yes, you can always compute the values you need for this to work in a separate worksheet, then use cell referencing to pull the value back into your original workbook. So, in a Sheet2 (for example), I would have two columns:
PENDING: =IF(Sheet1!$C4="Pending",1+LEN(Sheet1!$B4)-LEN(SUBSTITUTE(Sheet1!$B4,";","")),0)
FINISHED: =IF(Sheet1!$C4="Finished",1+LEN(Sheet1!$B4)-LEN(SUBSTITUTE(Sheet1!$B4,";","")),0)
Fill that formula as far down as needed.
Then, on your original sheet where you would like to enter the sums (I called it Sheet1 in the formulae above, you would do a =SUM(Sheet2!$B$1:$B$25) to populate the Amount Pending cell and =SUM(Sheet2!$A$1:$A$25) for the Amount Finished.
**
If you are not allowed to use a new worksheet, I would say a VB script would be the only other choice.
EDITED
Best solution is the SUMPRODUCT formula offered previously.

"dynamical" condition in Excel?

I want to have a "dynamical" condition in Excel as follows:
in Sheet2.Cell(C2)
If(AND(Sheet1!D2-Sheet1!C2<0;the sum of all cells, in the same row, however before
the current cell which is in this example: Sheet2.Cell(C2)!=0);0;Abs(Sheet1!D2-Sheet1!C2))
I tried with SUM and SUMIF but the problem is within the first cell and after that if I drop the formula the area is still fixed.
Sincethe problem is complicated I give here one example constructed by me which hopefully helps to clarify the problem. In the following pic we see a time series
the series in row 3 is permanently falling. The series in row 2 is from B2 to C2 falling but from C2 to D2 raising and the rest falling. Now In sheet 2 I want to recognize if a time series from sheet1 shows EVEN just one time raising behaviour and if yes from that cell I will put the difference but not Zero. Like in the following pic[]
That is not the most elegant solution but;
I calculated the first column (which is in my example B) as follows:
=IF((Sheet1!C2-Sheet1!B2)<0,0,ABS(Sheet1!C2-Sheet1!B2))
And in C2 I wrote
=IF(AND((Sheet1!D2-Sheet1!C2)<0,SUM($B2:B2)=0),0,ABS(Sheet1!D2-Sheet1!C2))
then I applied this formula to all fields! It works.
Disadvantage: the first column should be calculated before we would be able to apply it to the rest.

Average formula in Excel

I'm working on a spreadsheet and I need to have a set of cells ignored if they are blank. I tried a regular average formula as well as if statements and nothing seems to be working. The values need to be adjusted so they come to a common value. Here is the formula I am trying to use to calculate the average.
=(AVERAGE(D4,(F4*0.6),(H4*(6/7))))
This formula will calculate the average but is not ignoring cells that do not have a value.
Excel should automatically ignore truly blank cells when using the =Average() formula. However, if you do have some "0" data or space characters, you could use the following to find the average of anything that is numeric:
=SUM(A:A)/COUNT(A:A)
Where A:A is your range.
EDIT: Simplified to use Count which only finds numeric cells.
EDIT 2: Given your specific example, the average function could look as follows:
=IFERROR((D4 + (F4*0.6) + (H4*(6/7)))/COUNTA(D4,F4,H4), 0)

Dynamical SUMIF command

If it is possible, I'd like to create a formula that will allow me the following:
Formula must be in the entire column or in this example, in the range B1:B5. The formula is based on a condition, that when the total sum of cells from column A is lower D1, than it gives "X". If the total sum is over D1, then it gives an empty field - "".
In this example the total sum of the cells, that are over D1 value is in the first 3 rows, hence the three X-es, and then it stops.
(source: shrani.si)
.
I presume it would be possible to do this with multiple SUMIF commands, but does anyone know a smoother solution for this?
Thanks!
You can do this easily by using an absolute reference for the starting point of a SUM and using a relative reference for the end point. When copied down, this formulas works fine.
=IF(SUM($A$1:A1)<$D$1,"x","")
Results
Try this
=IF(SUM(OFFSET(A1,0,0,$A$1:A1,1))>$D$1,"X","")
This formula should start at B1 and then you use auto-increment to populate other cells

Resources