Using MIN IF function to find peaks and valleys in data - excel-formula

I have a cyclic data set. There are low cycles and high cycles, each with slightly different mins and maxes. i need to find the values of each min and max. I have attached picture of a simplified version of what I have. I know roughly what time the peak/valley will occur, so i thought i could use the min if function to isolate each extreme value. For example, it i wanted to find a valley between time 1 and time 5, i would use this formula:
=MIN(IF(1< time<5,data))
This just yields 0 for some reason. It sort of worked once but instead of isolating the minimum for the selected time period, it just found the minimum for the whole column. What am I doing wrong here? Is what i am trying to do possible without using VBA? This is a template for work that others will use and not everyone is able to use macro-enabled workbooks so I'd like to avoid that.

Use this:
=MIN(IF(time>5,IF(time<12,data)))
It is an array formula and needs to be confirmed with Ctrl-Shift-Enter

Related

Using IF with ROUNDDOWN, To Calculate How Many Times For A Process

I apologize if the title is a bit vague. I am trying to create a calculator that takes into account how much "scrap" I have, how much is needed to resmelt it, and how many bars recieved.
Currently using:
(=if((amtOwned/qtyToSmelt)<1,,rounddown((amtOwned/qtyToSmelt)*barsMade))
Table and Formula
The problem I am having is you MUST have the QTY to Smelt. But the value returned includes partial quantities.
Ex. 125 Bottle Caps should equal 4 Bars total. Yet it returns 5.
How can i make the formula only account for increments of the bars recieved?
Thank you for any help, again i apologize if this isn't that clear. Im not exactly sure how to express my need in this situation.
I have tried messing around with the syntax and where every argument sits, even this formula is the most recent iteration of what i thought would be needed.
EDIT: I have tried using the TRUNC function and this seems to be working as I need it to. The formula now is:
=TRUNC((AMTowned/AMTneeded),0)*barsRecieved
=TRUNC((136/50),0)*2 This is returning 2 bars instead of 3. Which is exactly what I need.
It appears this is working by truncating the number first then multiplying it. So, 1.5 becomes 1 before being multiplied. This was my guess after doing more research. I had been searching for a while before I posted this but am glad to have learned what I have in searching for this.
There is a tool for auditing formulas. To see it go to Formulas > Evaluate Formula.
So here is you formula =IF((E3/C3)<1,,ROUNDDOWN((E3/C3)*D3,0))
Have you tried the calculation on your regular calculator? To me it is doing what you would expect. (125/50)*2 = 5

Looking for a better formula in Excel to Calculate Duplicates

I have 621224 * 1 data in my Excel Sheet and have to calculate total no. of duplicates in the sheet but it takes a lot too much time with =IF(COUNTIF($J$1000:J14353,J5353)>1,1,0) so this formula might be taking n^2 complexity to find duplicates, I am looking for a formula that takes less time and if possible takes nlogn time, if there is in Excel
As of now I am doing this task manually taking a range of 10k which works in acceptable time and also to add on I have sorted the list
I searched for vlookup and found it will take around same time as countif
If you've sorted the data then you can use binary searching, which will be many times faster than your current linear set-up with COUNTIFS. For example:
=SUMPRODUCT(N(MATCH(A1:A750000,A:A)<>ROW(A1:A750000)))
On my machine, this produced a result in less than 1 second.
If you aren't able to first sort the data, if you have Office 365 you can perform the sorting in-formula:
=LET(ζ,A1:A750000,ξ,SORT(ζ),SUMPRODUCT(N(MATCH(ξ,ξ)<>SEQUENCE(ROWS(ζ)))))
which should still be very fast.
Ignoring IF() may faster. Try-
=SUM(--(COUNTIFS(A3:A13,A3:A13)>1))

VBA (Excel) which average more precise, worksheetfunction or step-wise

I wrote a macro which as a tiny task on the side also calculates the average of around 39000 different values. I noticed that using WorksheetFunction.Average and calculating the average "step-wise" yield different results, but only at the 15th digit after the decimal point. By calculating "step-wise" I mean adding up each value to a total_sum variable, counting the amount of values in another variable and then dividing the former by the latter.
The 15th digit after the decimal point might be considered negligible but I find it unsettling nonetheless. Shouldn't those two values be exactly the same? They are when I use less values and as the macro might be applied on far more values than 39000 (100k+), I'm worried the error might increase.
So my questions are: What could cause the difference and more importantly which method is more precise?
What I tried was to declare all variables in the "step-wise" calculation as Variant to avoid using the wrong data type in any of those steps.
Thank you very much for your help!

Removing Lower/Upper Fence of outliers from input data to then be evaluated

What I have attempted:
AVERAGEIF(B11:V11,">+MEDIAN(B11:V11)")
What I am trying to do:
I would like to take the average of the upper half of given data. Elaborating more. I would like to find a formula that will allow me to remove a given lower fence of outliers and dissect the data then given to me. I would greatly prefer to maintain this formula within one cell "not grabbing different results from formulas within multiple cells".
Update:
Following through I found the solution.. I think.
One thing I should have explained further:
The data coming in replicating a typical sqrt function.
What I wanted to achieve is to capture the mean of the "plateau" of the data.
The equation I used was:
=AVERAGEIF(B3:B62,(">"&+TRIMMEAN(B3:B62,0.8)),B3:B62)
This was something I just copied and pasted. of course "B3" and "B62" are significant only for my application.
My rough explanation of the equation:
TRIMMEAN will limit the AVERAGE to the top 20%(">")(0.8) of the data selected. So for my application, this SHOULD give me a rough mean of the "plateau" of the data i would like to find the mean for.
This formula calculates the Median() of the range, then AverageIf() uses the median and only grabs values that are greater than or equal to >= the median ~ giving you the average of the 'top-half' of your values.
AVERAGEIF(A1:A10,">="&MEDIAN(A1:A10))
Hope this help!

Average using a difference from MAX in Excel

I am trying to average a column of numbers, throwing out values a specific difference from MAX. The users will not be Excel experts, so I am trying to stay away from Array formulas so they can edit the difference number based on different conditions.
=AVERAGEIF(DM7:DM34,"=>Max(DM7:DM34)-3",DM7:DM34)
This returns a #Div/0, while the MAX portion alone returns the value I need.
I think what you may require is something like:
=AVERAGEIF(DM7:DM34,">="&MAX(DM7:DM34)-3)
You might achieve some added "comfort" by changing 3 in -3 to a cell reference where the difference number would be placed/changed.

Resources