Having trouble in formulating rules in excel - excel-formula

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).

Related

count how often a piece of information appears and calculate that average

I do not want to know the traditional frequency or the traditional averages; so I'll give an example below:
I have this data:
1
3
5
5
2
3
5
5
1
3
The analysis that I would like to obtain is the following:
for example number 1 appears once every eight rows, number 3 appears once every four rows, number 5 appears twice every two rows....
I did it by hand, but now I have more than 21000 rows of data and I'm stuck.
I searched but I can not find a function that does it; But before I started developing my own, I decided to ask for a guide on how to achieve it.
I believe that I was able to achieve the desired result:
The formula is:
Or, if you want to copy/paste:
=IF(CONCATENATE("1-",MATCH(D1,INDIRECT(ADDRESS(MATCH(D1,A1:A17,0)+1,1,4)&":A17"),0))="1-1",CONCATENATE("2-",MATCH(D1,INDIRECT(ADDRESS(MATCH(D1,A1:A17,0)+2,1,4)&":A17"),0)-1),CONCATENATE("1-",MATCH(D1,INDIRECT(ADDRESS(MATCH(D1,A1:A17,0)+1,1,4)&":A17"),0)))
Note that the IF function solves the duplicates (like the number 5). In case you have triplicates you will have to add another instance of IF and adjust the formula accordingly.
Hope that helps!
Well this doesn't exactly reproduce your results, but you could start by looking at the max and min separation of the numbers:
=IF(COUNTIF(A$1:A$10,C2)<=1,"",MIN(IF((ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))>1)
*(ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))<=COUNTIF(A$1:A$10,C2)),
FREQUENCY(IF(A$1:A$10<>C2,ROW(A$1:A$10)),IF(A$1:A$10=C2,ROW(A$1:A$10)))))+1)
=IF(COUNTIF(A$1:A$10,C2)<=1,"",MAX(IF((ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))>1)
*(ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))<=COUNTIF(A$1:A$10,C2)),
FREQUENCY(IF(A$1:A$10<>C2,ROW(A$1:A$10)),IF(A$1:A$10=C2,ROW(A$1:A$10)))))+1)
This gives the min or max number of rows between each occurrence of the particular number.
Must be entered as an array formula using CtrlShiftEnter
You could add other statistics (like mean, standard deviation) the same way although the average could be calculated just by (lastrow-firstrow)/(count-1) e.g. for 5 it would be (8-3)/(4-1)=5/3.

how I can divide a sum number into 50 column in ecxel?

I would like to tell, with a smaller number of columns.
Let's say we have a sum of 24 and we want to distribute it randomly into 10 separate columns. we should get such a result as below I wrote.
Is there a formula in Excel like this?
Thanks in advance.
Ok. Here is what I would do...
For each required split, select a random number between zero and the remainder of the distribution qty, multiplied by the percentage of how many splits have already been calculated. This prevents the first few splits being very high, and the rest being zero.
I would also add a check for the very last split to make sure that it equals whatever is left of the original distribution qty.
Here is an image for illustration and the formula that I have used:
=IF($A2=MAX($A:$A),$F$1-SUM($B$1:$B1),RANDBETWEEN(0,($F$1-SUM($B$1:$B1))*($A2/MAX($A:$A))))
Hopefully, this isn't too complex to understand. If you need further explanation, please let me know.
You can simply change the distribution qty in the yellow box, and if you want more splits, all you need to do is drag down columns A & B to the required number.

Excel Sumif, Sumifs with partial strings in multiple columns?

So this is the simplified question I broke down from a former question I had here: Excel help on combination of Index - match and sumifs? .
For this one, I have Table1 (the black-gray one) with two or more columns for adjustments for various order numbers. See this image below:
What I want to achieve is to have total adjustments for those order numbers that contain the numbers in Total Adjustment column in the blue table, each of which will depend on the cell beside it.
Example: Order number 17051 has two products: 17051A (Apple) and 17051B (Orange).
Now what I want to achieve in cell C10 is the sum of adjustment for both 17051A and 17051B, which will be: Apple Adjustment (5000) + Orange Adjustment (4500) = 9500.
The formula I used below (and in the image) kept giving me error messages, and this happens even before I add the adjustment for Orange.
=SUMIF(Text(LEFT(Table1[Order Number],5),"00000"),text(B10,"00000"),Table1[Apple Adjustment])
I have spent the whole day looking for a solution for this and didn’t even come close to find any. Any suggestion is appreciated.
Assuming your headers always have the text "adjustment" in them, you could use:
=SUMPRODUCT((LEFT($B$4:$B$7,5)=B10&"")*(RIGHT($C$3:$F$3,10)="adjustment")*$C$4:$F$7)
In C10 you could add two sumproducts. This assumes that products are always 5 numbers long at the start. If not swop the 5 to use the length of the product reference part you are matching on.
=SUMPRODUCT(--(1*LEFT($B$4:$B$7,5)=$B10),$D$4:$D$7)+SUMPRODUCT(--(1*LEFT($B$4:$B$7,5)=$B10),$F$4:$F$7)
Which with table syntax is:
=SUMPRODUCT(--(1*LEFT(Table1[Order Number],5)=$B10),Table1[Apple Adjustment])+SUMPRODUCT(--(1*LEFT(Table1[Order Number],5)=$B10),Table1[Orange Adjustment])
Using LEN
=SUMPRODUCT(--(1*LEFT(Table1[Order Number],LEN($B10))=$B10),Table1[Apple Adjustment])+SUMPRODUCT(--(1*LEFT(Table1[Order Number],LEN($B10))=$B10),Table1[Orange Adjustment])
I am multiplying by 1 to ensure Left, 5 becomes numeric.

Excel Count down Issue?

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.

Excel MATCH with Criteria

I wonder if someone could help me with this issue?
I have a ranking table and want to MATCH the 5 lowest ratio items (as per below).
=MATCH(SMALL(RankMthRat,1),RankMthRat,0)
=MATCH(SMALL(RankMthRat,2),RankMthRat,0)
=MATCH(SMALL(RankMthRat,3),RankMthRat,0)
=MATCH(SMALL(RankMthRat,4),RankMthRat,0)
=MATCH(SMALL(RankMthRat,5),RankMthRat,0)
It is possible that the 5 lowest values are all 0%, in which case I would the MATCH position of all 5.
But because of the 0 value the returned MATCH position for all 5 of the above is the same.
Is it possible to MATCH but ignore previous results? IE the third formula is returns result that is not equal to the first and second?
(RankMthRat is a single column of percentages).
Many thanks
A standard way of doing this, although you might not consider it to be very elegant, is to add a small amount to each row based on the row number
=MATCH(SMALL(INDEX(RankMthRat+ROW(RankMthRat)*0.00001,0),ROW()-ROW($1:$1)),INDEX(RankMthRat+ROW(RankMthRat)*0.00001,0),0)
entered in (say) C2.

Resources