Good Afternoon,
I'm creating a table which presents the average and standard deviations for a variety of metrics. This table can be filtered by date and location where the measures were taken. Thankfully, there is an AverageIf function, but there is no such function for standard deviation. This is my attempt:
{=STDEV.S(IF(**BPMS[Location]=$M$2**, IF(BPMS[Pre Date]>=$Q$1, IF(BPMS[Pre Date]<=$Q$2, BPMS[PRE Internalizing Raw], ""), ""), ""))}
M2 contains a drop-down list full of locations. One of those entries is an asterisk (*), which I would like to stand for any location. This works for the AverageIf formula, as * is usually a stand in for any value in excel formulas, but it's not working for the above formula. How can I write the formula to allow for a specific locations OR any location?
Thanks for the help!
Related
I have a recorded drive cycle of a truck which includes speed and coordinates over time. The file looks like this (simplified version)
I want to know the number of times the truck is stopped (when speed = 0) and number them. Therefore, I would like to group the intervals with '0' values (vehicle stopped) in the Speed column and name them in order (Stop 1, Stop 2, etc). Ultimately, my goal would be to somehow be able to calculate the number of stops and duration like this:
Is there any function in Excel which would allow me to do something like that? Thank you.
You can do it using Pivot Tables and a helper column. Also if you have Excel365 with functions like FILTER,UNIQUE and SUMIFS
Formula helper column is just to enumerate properly each group of stops. Notice data need to be sorted properly as your exampel or it won't work:
=IF(D2="STOP";IF(D1="STOP";E1;MAX($E$1:E1)+1);"")
Then pivot table can be inserted:
Helper Column and Vehicle Stop into rows section
Time-step seconds into values section, formated as Time and operation=Sum
Filter field Helper Column to exclude blanks
If you have Excel 365, you can get this output with advanced formulas. In cell J14 formula is:
=UNIQUE(FILTER(D2:D19&E2:E19;D2:D19="STOP"))
And K14 is (and drag down) is:
=SUMIFS($B$2:$B$19;$D$2:$D$19;"STOP";$E$2:$E$19;MID(J14;5;99))
Anyways, I've uploaded the workbook to Gdrive so you can see the Pivot Table and the formulas by yourself. If you don't jave Excel 365, the formulation part may give some errors when you open it:
https://docs.google.com/spreadsheets/d/1t1INxGKJRHFexWnSC5LlIi37JrThjajs/edit?usp=sharing&ouid=114417674018837700466&rtpof=true&sd=true
Just as a postscript to this, you could do the same thing without using helper columns by comparing offset ranges to see where the transitions in speed occurred from 0 to 10 (go) or 10 to 0 (stop). The problem is that normally you would have to go outside the data range (a2:a16 and c2:c16) which gets you either a header cell (a1 or c1) or a blank cell (a17 or c17). In the case of time, there is also a special case where the first time-step is taken to be zero.
All this can be avoided in Excel 365 by using vstack to add appropriate dummy values to the beginning or end of the two ranges:
=LET(timeRange,A2:A16,
speedRange,C2:C16,
timeRange1,VSTACK(A2,timeRange),
speedRange1,VSTACK(1,speedRange),
speedRange2,VSTACK(speedRange,1),
startTime,FILTER(timeRange1,(speedRange1>0)*(speedRange2=0)),
endTime,FILTER(timeRange1,(speedRange1=0)*(speedRange2>0)),
stopTime,endTime-startTime,
label,"STOP "&SEQUENCE(ROWS(stopTime)),
HSTACK(label,stopTime))
(Pictures included) -
I'm trying to write a formula that sums the Forecast Qty (dynamic range) based on multiple criteria. The criteria I want to base it on is the Part number and the month (Aug-21, Sep-21 etc). Each part can have multiple forecasts for each month, I've ran a match formula that shows the first row in which each part changes, but am not sure how to necessarily break it down further into months.
The previous pictures will give more insight into what I want. The first picture shows my raw data and the Match function I performed to find the first row of corresponding part. The second picture shows where I'd like the end result. The '100' in the selected cell is the result of the formula I have ran below.
=IF(VLOOKUP(F2,HIghJump!B:F,4,FALSE)>DATEVALUE("9/01/2021"),SUM(HIghJump!F2:F6))
My issue is how do I get the range in the sum formula (F2:F6), to change based on corresponding month. Beyond that, how do I get this formula to change based on different parts and different numbers of forecasts per month.
Any help is greatly appreciated!
Use SUMIFS:
=SUMIFS(HIghJump!$F:$F,HIghJump!$B:$B,$F2,HIghJump!$E:$E,">="&EOMONTH(K$1,-1)+1,HIghJump!$E:$E,"<"&EOMONTH(K$1,0)+1)
This should go in L2 and copy down. Change the K$1 to each corresponding target date when moving over columns.
If I am understanding correctly and if you have the newest version of Excel, then FILTER will come in handy.
Try:
=SUM(FILTER(HIghJump!F:F,
(HIghJump!B:B=$F2)*(HIghJump!B:B>=K$1)*(HIghJump!B:B<EOMONTH(K$1,0)+1))
Note that it is generally considered best practice to use partial ranges (e.g. $B$1:$F$100 and $B$1:$B$100 instead of B:F and B:B), so that might be something you would want to consider if performance is of importance to you. Also make sure your sheet name is really "HIghJump" instead of "High Jump" or some variation.
Answer:
Had to create a column using MONTH(x), then base SUMIFS off that vs the original month column.
=SUMIFS(HIghJump!F:F,HIghJump!H:H,MONTH(K$1),HIghJump!B:B,F2)
To simplify the screening of candidates for a college program, we created an Excel sheet compiling information provided by candidates.
They had to select one or more academic achievements from a droplist (some have none, some have 25).
The result in the Excel file is a cell for each student/row where the achievements are separated by line breaks.
We have a table where each of the possible achievement is worth a certain number of points.
For instance, a master's degree is worth 4, a published article is worth 2, etc.
We want to add a column that states the number of points a candidate has based on the cell that contains one or more achievements.
How can we do that with Excel?
Thank you!
Table with weighted value of achievement
Desired result
Ideally, some students have multiple occurrences of an achievement and we would want to take it into account (for instance, published two articles = 6 points) but that's a nice-to-have.
As of now, I have tried:
Combining SUM and VLOOKUP function, but I can only seem to recognize one value per cell
Experimenting with the SUMIF function, but that did not seem to work for me
Experimenting with nested conditions
Adapting solutions that require multiple criteria in multiple cell (for instance, return price if the row contains dress and blue, but none seem to apply for the situation when there are multiple strings in a single cell.
VLOOKUP works but you have use an array for lookup_value consisting of each achievement. Since the achievements are from a drop-down, we can assume they are spelled correctly.
We can use FILTERXML to split the entry by the line-feeds into an array of separate nodes, and then use that to find the appropriate values.
FILTERXML is in Windows Excel 2013+ but not available in Excel for MAC or online. If necessary, I can supply a different function to do the splitting.
For example:
=SUM(VLOOKUP( FILTERXML("<t><s>"& SUBSTITUTE(E2,CHAR(10),"</s><s>") & "</s></t>","//s"),AchieveTbl,2,FALSE))
AchieveTbl
Results
Alternatively you could use =SUM((LEN(SUBSTITUTE(E2,$A$2:$A$8,$A$2:$A$8&"_"))-LEN(E2))*$B$2:$B$8)
This is based on an answer here
Columns A & B contain a sample of data, with shop being an identifier (only two shown here)
I've setup two ranges in columns D & E which I can use the DSTDEV() function in column G
e.g. G2 formula is =DSTDEV($A$1:$B$9,2,D1:E2)
and G4 formula is =DSTDEV($A$1:$B$9,2,D4:E5)
so the output currently is:
But in reality I have a tonne of shop identifiers so I wanted to be able to use the DSTDEV() as a flood-fill formula, ideally with an output like so:
Where I could calculate the standard deviation in column E for each shop in column D
I basically wanted DSTDEV() to work like SUMIF() but the criteria has to be a range, and I'm looking for a way round that?!
I thought I would ask before I go creating a UDF to do what I needed!
I tried supplying a split range in the format e.g. (E1,E3) as the criteria but that didn't work
An option would be using Pivot Tables:
Subtotal and total fields in a PivotTable
StDev: An estimate of the standard deviation of a population, where the sample is a subset of the entire population.
This will return exactly the result you want, besides it's really easy to manage and setup
Another option would be use of the STDEV.P function integrated with FILTER. This relies on two premises:
STDEV.P calculates the population standard deviation based upon a list of values
FILTER can generate a dynamic array of values based on a single criteria when compared against a query list
So a FILTER array would look like this:
Now that the list of individual values have been generated, this can simply be wrapped with the STDEV.P (or any other function based on lists) like this:
From there, you can anchor all elements except for the bold cell, and then flood fill accordingly:
=STDEV.P(FILTER(B2:B9,A2:A9=**D2**,))
Alternatively, it may be useful to include headers and named dynamic ranges via PivotTable, and you could avoid anchoring the formula.
I am using this formula for SUMIF which is working fine, but I need to add another criteria which is the DATE. I only want the jobs to sum total if the date is the same in column A. How do I accomplish this? When I use SUMIFS I get an error "too few arguments".
=SUMIF($B$2:$B$786,I2,$F$2:$F$786)
Setting the Stage
When making my initial response, I didn't notice that the OP's sample data included two separate data ranges. There is the main "table" with columns including DATETIME, PRODUCT and AVG CYCLE MINUTES. These are the data to be summed across. However, the sums are not to appear against these rows, but against the rows in the second "table" which has the column REFERENCE LIST. REFERENCE LIST matches with the PRODUCT column in the first table and so provides one of the criteria for the SUMIF(S). The second criteria was to be DATE. However, since the second table doesn't include a date column it isn't obvious where this should come from.
In discussion with the OP, we realised that we wanted a the total (or, as it turned out, average) of "AVG CYCLE MINUTES" for each combination of DATETIME and PRODUCT. I walked the OP through the process of creating a PivotTable to do this.
Options
If we want to achieve the same or similar by means of SUMIF or SUMIFS, we need to make a decision about the DATE criteria. Either (a) the second table needs to include dates as well as PRODUCTs, or (b) we need to find a way to pick the date we're interested in.
Sum for Every Combination of DATE and PRODUCT
For option (a), an answer similar to my original one would work:
=SUMIFS(F:F,B:B,I2,A:A,J2)
where column J is the new column of dates. The full list of date/product combinations could have been swiftly produced by copying the relevant columns of the main data to elsewhere and using Excel's "remove duplicates" functionality.
Sum for single DATE per PRODUCT
For option (b), if you wanted to sum up all the data relating to "today", that could be done using:
=SUMIFS(F:F, B:B, I2, A:A, today())
(with credit to #JNevill).
What else might we want? Perhaps the most recent date the PRODUCT appears against? Or the earliest? If you have EXCEL 2016 (or better) ...
=SUMIFS(F:F, B:B, I2, A:A, MAXIFS(A:A,B:B,I2))
This would give the total minutes for the relevant PRODUCT on the latest date recorded for that PRODUCT. For the earliest date replace MAXIFS with MINIFS.
Alternatively, if the data is sorted so that the date you want will be the first to appear against any given PRODUCT you can use:
=SUMIFS(F:F, B:B, I2, A:A, INDEX(A:A,MATCH(I2,I:I,0)))
Miscellanea
I'd normally use VLOOKUP rather than INDEX/MATCH (a habit I've yet to acquire), but in the current data structure the columns are in the wrong order for that.
Since further discussion revealed that the OP actually wanted averages not totals, it's worth noting the existence of AVERAGEIFS.
NOTE: in my original answer (below), I reference the exact ranges rather than entire columns. There may be some marginal performance loss doing things as above, but I've never noticed. Though you need to be sure there are no extra data beneath the stuff you're interested in. On the other hand, there are definite benefits, it's easier to enter the formula and it will not need amending for larger (or smaller) data sets. (Thanks for reminding me of this #Jeeped)
NOTE 2: Since there is there is nothing you can do with SUMIF that can't also be done with SUMIFS, there is no harm in using the latter even when the former would suffice. That way you only have one function to remember and it's the most useful one. (Another good idea from #Jeeped)
Original Answer
As others have said, I think you want SUMIFS. Here the sum_range comes to the front, and you follow that with pairs of "criteria range"s and "criteria" like this:
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
In your case, I think that means you want:
=SUMIFS($F$2:$F$786,$B$2:$B$786,I2,$A$2:$A$786,A2)
When I wrote this, the relevant Microsoft Support page was here