I have this pivot table that produce this table,the first column is pending days which represent how long the part is requested till today the next one is part code and next to it I have Total amount of my Inventory. what I want to do is a formula that allocate a number to the fields if their total-amount is > 0.
here is where my problem lies:
if you pay attention to the red ones their total amount is 3 but we have four request from this part and I want for the last one instead of number 1 the formula insert #N/A so that I can Comment correctly.
like this:
appreciate any help in advance.
You can use a COUNTIF function with a relevant and absolute reference to see whether the total amount of parts has already been reached. Try this:
=IF(COUNTIF($B$2:B2,B2)>C2,NA(),1)
Broken down, this formula counts how many of the parts have already been requested and if this exceeds the total amount of parts it will return #N/A, otherwise it will return 1.
Related
Example:
1 3 2 4 5 6 7
Rules:
If it is the first time a number is greater than its previous number, retrieve the number (3 in this instance);
If after the retrieved number, the subsequent number is less than or equal to "the retrieved number - 1", discard the retrieved number (3 will be discarded)(back to Rule (I), number 4 will be chosen);and
If the subsequent number is greater than the number retrieved, store the difference between subsequent numbers and number retrieved, show the largest difference between subsequent numbers and number retrieved(in this case 7-4)
I tried to formulate the rules in excel but I am stuck at Rule (II).
Let me know if I am unclear, I'll try to be as explicit as possible. Thanks
Not 100% sure I got the rules exactly right, but maybe this will help.
I put the numbers in a column and made two helper columns. See the image.
In B3, enter
=IF(LEN(B2)=0,IF(A3>A2,A3,""),IF(A3<=B2-1,IF(A3>A2,A3,""),B2))
and fill down.
In C3, enter
=IF(LEN(B3)=0,"",IF(B3<A3,A3-B3,""))
and fill down.
The largest difference will be =MAX(C:C).
I have a large spreadsheet and I am struggling to get an average, no formula I have used thus far from google or otherwise, has worked.
The average is an average of time, in particular, hours between a start and end time, converted into days.
In column E9:E1833, I have start time as dd/mm/yyy hh:mm
In column J9:J1833, I have the time in days, from start to finish as [h]:mm (some are empty)
I have an auto filter setup to change with job type / area / status etc, and the result needs to change as data is filtered.
The following formula works, but does not recalculate:
{=AVERAGE(IF(MONTH(E9:E1833)=1,(J9:J1833)))}
The following formula works, but gives an incorrect result:
=AVERAGE(IF(MONTH(E1833)=1,SUBTOTAL(101,(J9:J1833))))
I have tried Offset, with similar results, and many of the "off-the-shelf" solutions produces #Div/0, #REF, #Value or fail to allow the entry altogether.
Any help would be much appreciated, preferably not in VBA, as I don't want to be lumbered with this spreadsheet forever. Thanks in advance.
Since you are going to be filtering, and want the result to change as you filter, just use the AGGREGATE function:
=AGGREGATE(1,3,J:J)
EDIT: Animation added in response to question
The values in the Values column can be times, although you may have to format the result of the AGGREGATE function (cell/numberformat) to show the result as [h]:mm
Note: GIF will play twice. To repeat, refresh the page
The following formula seems to work.
{=AVERAGE(IF(SUBTOTAL(9,(OFFSET(J9:J1833,ROW(J9:J1833)-MIN(ROW(J9:J1833)),0,1)))>0,(IF(MONTH(E9:E1833)=3,SUBTOTAL(9,(OFFSET(J9:J1833,ROW(J9:J1833)-MIN(ROW(J9:J1833)),0,1)))))))}
The SUBTOTAL(9,OFFSET part of the function returns an array where filtered numbers are 0, and visible numbers return their values. If you just averaged that array, you would get the wrong number because you would be averaging all those zeros. So the IF statement just creates an array that returns a FALSE for zero, which is not averaged.
An additional caution that gave me a headache as I was playing around, was you are also filtering on MONTH()=1. The issue with that is, blank cells return a January date, which means they will not be filtered by MONTH()=1
I'm trying to perform an AVERAGEIFS formula on some data, but there are 2 possible results and as far as I can tell AVERAGEIFS doesn't deal with that situation.
I basically want to have an ELSE inside it.
At the moment I have 2 ranges of data:
The first column only contains values 'M-T' and 'F' (Mon-Thurs and Fri).
The second column contains a time.
The times on the rows with an 'F' value in column 1 are an hour behind the rest.
I want to take an average of all the times, adjusting for the hour delay on Fridays.
So for example I want it to take an average of all the times, but subtract 1 hour from the values which are in a row with an 'F' value in it.
The way I've been doing it so far is by having 2 separate results for each day, then averaging them again for a final one:
=AVERAGEIFS(G3:G172, B3:B172, "M-T")
=AVERAGEIFS(G3:G172, B3:B172, "F")
I want to combine this into just one result.
The closest I can get is the following:
=AVERAGE(IF(B3:B172="M-T",G3:G172,((G3:G172)-1/24)))
But this doesn't produce the correct result.
Any advice?
Try this
=(SUMPRODUCT(G3:G172)-(COUNTIF(B3:B172,"=F")/24))/COUNTIF(B3:B172,"<>""""")
EDIT
Explaining various steps in the formula as per sample data in the snapshot.
SUMPRODUCT(G3:G17) sums up all the value from G3 to G17. It gives a
value of 4.635416667. This after formatting to [h]:mm gives a value
of 111.15
OP desires that Friday time be one hour less. So I have kept one hour less for Friday's in the sample data. Similar SUMPRODUCT on H3:H17 leads to a value of 4.510416667. This after formatting to [h]:mm gives a value
of 108.15. Which is exactly three hours less for three occurrences of Fridays in the sample data.
=COUNTIF(B3:B17,"=F") counts the occurrences of Friday's in the B3:B17 range which are 3 occurrences.Hence 3 hours have to less. These hours are to be represented in terms of 24 hours hence the Function COUNTIF() value is divided by 24. This gives 0.125. Same is the difference of 4.635416667 and 4.510416667 i.e. 0.125
Demonstration column H is for illustrative purposes only. Infact Friday accounted values that is 108.15 in sample data has to be divided by total data points to get the AVERAGE. The occurrences of data points are calculated by =COUNTIF(B3:B17,"<>""""") with a check for empty columns.
Thus 108:15 divided by 15 data points give 7:13 in the answer.
Revised EDIT Based upon suggestions by #Tom Sharpe
#TomSharpe has been kind enough to point the shortcomings in the method proposed by me. COUNTIF(B3:B172,"<>""""") gives too many values and is not advised. Instead of it COUNTA(B3:B172) or COUNT(G3:G172) are preferable. Better Formula to get AVERAGE as per his suggestion gives very accurate results and is revised to:
=AVERAGE(IF(B3:B172="M-T",G3:G172,((G3:G172)-1/24)))
This is an Array Formula. It has to be entered with CSE and further cell to be formatted as time.
If your column of M-T and F is named Day and your column of times is named TIME then:
=SUMPRODUCT(((Day="M-T")*TIME + (Day="F")*(TIME-1/24)))/COUNT(TIME)
One simple solution would be to create a separate column that maps the time column and performs the adjustment there. Then average this new column.
Is that an option?
Ended up just combining the two averageifs. No idea why I didn't just do that from the start:
=((AVERAGEIFS(G$3:G171, $B$3:$B171, "F")-1/24)+AVERAGEIFS(G$3:G171, $B$3:$B171, "M-T"))/2
Myself and some friends are taking part in a weight loss challenge this year and I will be recording monthly weigh in's and body measurements. I need to find a calculation which will work out the difference's in inches and pounds.
I have the item title in column B from row 10 down to Row 17. The first one in Row 10 is weight which is calculated in pounds.
Then going across from Column C is the month starting with Jan ending in December in Column N.
The total loss needs to be updated after every monthly entry into column O.
Unfortunately I cannot post a picture of the table as I'm new to this group.
I've tried other formulaes suggested to people with similar problems but they don't work for me.
Can anyone help?
Many Thanks
Helen
Bit hard to work it out from your description but I think you are looking for
=C10-MIN(D10:N10)
That assumes the largest figure will always be in column C and will update every time a new entry is placed in the row.
If the weight might go up (not that you are going to fail the challenge) you could use
=C10 - LOOKUP(1,1/(D10:N10<>""),D10:N10)
This should do the trick. (And you can copy down to other rows as necessary)
=INDEX(C10:N10,1,COUNT(C10:N10))-C10
INDEX used here, returns the value from the range C10:N10 in the first and only row, where the column is determined by the count of values already entered. So if you have values entered for 4 months, the formula will take April's value and subtract January's value.
A negative number will represent weight loss. A positive number means weight gain.
Total fat loss :
(AVERAGE(C10:N10) - C10)*2
I've got data that looks like:
Date |ID Number
9/6/2013 |ABCDE
11/26/2013 |LMNOP
3/25/2014 |VWXYZ
3/27/2014 |VWXYZ
4/8/2014 |VWXYZ
4/10/2014 |VWXYZ
I was wondering if there was a code that would allow me to count up a particular number of times an ID Number was associated with a particular month. My data has been sorted by ID Number, and I need to know how many times the Number occurs per month.
For example, I would need to know that in a column for March that VWXYZ occurred twice, and the same in a column for April. I need to know if there is a formula for automatically searching for the ID Number and counting how many times that Number is associated with a particular month. Everywhere I look, it involves manually entering the ID Number into the formula. I have almost two thousand entries in my data sheet, and I was hoping there was an easier way.
This has stumped me for days, and any help is greatly appreciated.
If Date is in A1, the start date for your chosen month is in D1 and the string to search for in E1 please try:
=COUNTIFS(A:A,">="&D1,A:A,"<="&EOMONTH(D1,0),B:B,E1)
Edit re OP's comment to question
In row2 and copied down to suit:
=COUNTIFS(A:A,">="&EOMONTH(A2,-1)+1,A:A,"<="&EOMONTH(A2,0),B:B,B2)