(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)
Related
I have 2 columns one is a period and another is a cycle. I need to create a 3rd column where I create a cycle identifier. Where the Letter changes on the cycle but resets every period.
I seem to have it with the following formula
IF(A1<>A2,1,IF(B1<>B2,C1+1,C1)). Which will give results of 1, 2 or 3. Then to get the numbers into letter form by using a switch SWITCH(C1,1,"A",2,"B",3,"C") in an adjacent cell. However I was curious if there is a more efficient or better way to accomplish this perhaps in all in one formula.
Any suggestions would be greatly appreciated.
Period & Cycle
Copy this formula to cell C2 and copy it down.
=IF(B2<>B1,IF(A2<>A1,CHAR(65),CHAR(CODE(C1)+1)),C1)
In Excel 365, you could use a spill formula like this:
=CHAR(B2:B15-XLOOKUP(A2:A15,A2:A15,B2:B15)+65)
You could argue that this is less efficient because it uses a lookup so there could be a speed hit with large amounts of data. On the other hand, it could be considered more efficient because it is a single formula and doesn't need to be pulled down.
If you were worried about the speed, you could set the binary search option in xlookup:
=CHAR(B2:B15-XLOOKUP(A2:A15,A2:A15,B2:B15,,2)+65)
(Column A has to be sorted ascending for this to work - I'm fairly sure that where there are duplicates this will still give the first match. However Microsoft are quoted as saying that there is only a slight benefit of using binary search according to this and other articles)
You could make the formula more dynamic:
=CHAR(B2:INDEX(B:B,COUNTA(B:B))-XLOOKUP(A2:INDEX(A:A,COUNTA(A:A)),A2:INDEX(A:A,COUNTA(A:A)),B2:INDEX(B:B,COUNTA(B:B)))+65)
Or using Let
=LET(Period,A2:INDEX(A:A,COUNTA(A:A)),
Cycle,B2:INDEX(B:B,COUNTA(B:B)),
CHAR(Cycle-XLOOKUP(Period,Period,Cycle)+65))
I have created an excel sheet to have an overview over costs in my projects, however, I also need an overview of costs per category in my projects. I googled it and tried to find examples online, however, it only returns a value of 0, which shouldn't be the case. Can anyone help me? The sheet looks like below.
I am going by the SUMIF function to group by category but my excel sheet is a bit more complex than that so I tried to adjust it accordingly as seen in the code below. No matter what I do it either returns an error or 0.
=IF(B12=B8;"";SUMIF(B12:B39;B12;J12:BE39))
In the formula above I am trying to sum the costs of a category that could be written in B12, for example, Software development. For confidential reasons, I cannot show the actual filled out excel sheet.
sumif does not work with summing multiple columns. Instead use a sumproduct statement instead like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$BE$39)))
A detailed explanation to how this works can be found here
Edit:
I sense a follow up question coming, how to skip certain columns. Because as you have set it up now, it will count the entire range from J12 to BE39, in which you have both forecast costs and actual costs. I guess this is to compare the costs to what was projected and what the actual costs are. Right now it will count both the projected and actual cost, doubling up. To prevent this you can enter every second column separated by a + like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$J$39+$L$12:$L$39+$N$12:$N$39)))
Also I have added $ signs to all non-changing values so it will work when dragging down the fill handle on the formula to populate the below cells.
I have a Simple spreadsheet with 2 rows:
ActualJAN | BudgetJAN | ActualFEB | BudgetFEB | ActualMAR | BudgetMAR ....
100 200 300 400 500 600 ....
I'd like to sum ONLY the Budget columns up to the current month (Month(Today()).
Same for the Actual columns.
So if we're currently in February,
Budget to date would be: 600=200+400
Actual to date would be: 400=100+300
I just can't seem to get there, at least simply and elegantly.
This is a non array formula that performs array like operations. As such large range references should be avoided or you will experience a slow down or potential crash of your system. For a small defined range works great so long as the formula is not repeated too many times either.
Additionally TODAY() is a volitile function which means the formula will recalculate whenever anything in the spreadsheet changes, not just when something related to the formula changes.
This formula is generalized a bit so your data can be located anywhere on your sheet and does not require rearrangement of your data.
To get your actual sum use the following:
=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="A"))
To get your Budget sum use the following:
=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="B"))
Change C4:H4 to suit your number range. ChangeC3:H3 to suit your column title range. Change C4 to be the first cell of your number range.
Caveat: Assumes maximum 12 months starting at January
Proof of concept:
I would recommend structuring your data differently. It would be an easier task if you arrayed everything vertically and divided your data into three columns. The first would be Category, which would be populated with either "Budget" or "Actual." The next column would be Month. After that, of course, you have the Value column. Then, use a basic SUMIF, like "=SUMIF(A1:A6,"Budget",C1:C6)." A1:A6 is the range Excel will scan for the desired variable. In this case, that variable is "Budget." Then, C1:C6 is the value that corresponds to a "Budget" month. That formula will give you the answer you want as long as you expand the SUMIF formula to include the full range of values, e.g., "SUMIF(A1:A317,"Budget",C1:C317)."
So I think I understand what you're trying to do, I cannot make the entire formula without the rest of the spreadsheet but this is working currently:
For the Actual:
=IF(MONTH(TODAY())=1,A2,IF(MONTH(TODAY())=2,A2+C2,IF(MONTH(TODAY())=3,A2+C2+E2,"")))
For the Budget:
=IF(MONTH(TODAY())=1,B2,IF(MONTH(TODAY())=2,B2+D2,IF(MONTH(TODAY())=3,B2+D2+F2,"")))
Here is the spreadsheet I created to test:
If you give me the rest of the data I can complete the formula, basically all you would need to do is add more months to the formula and change the amounts it adds.
I am sure there is probably a more efficient way to accomplish this but this way works.
I suggest a hidden row to control your dates. Say, January is in column C, enter [C1] =1, [D1] =C1, [E1] =C1+1, [F1] =E1. Select E1:F1 and copy to the right until December. Hide row 1.
In row 2 use these two formulas.
[C2] ="Actual" & UPPER(TEXT("1/" & C$1,"mmm"))
[D2] ="Budget" & UPPER(TEXT("1/" & D$1,"mmm"))
Select C2:D2 and copy to the right until December. This exercise isn't required because the resulting display is exactly what you already have. But producing this result with the help of formulas ensures freedom from error, and it is faster. As an added bonus you get a visual check of what's in the hidden row.
Now you can use this formula to extract totals from row 3 where you have your values.
=SUMIFS($C3:$Z3,$C$2:$Z$2,"Budget*",$C$1:$Z$1,"<="&MONTH(TODAY()))
Change "Budget" to "Actual" and the same formula will extract the actual amounts.
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
I'm looking for advice on how to approach a certain problem.
In short, I have a matrix with two descriptive columns to the left (Y-axis) and a range of durations/time periods on the X-axis. The first column include bond types, and the second currency. There are 6 kinds of bonds, and 4 currencies. Every combination can have one of four durations.
The problem is that I recieve the mentioned matrix weekly, and the number of rows is different each time because only non-blank rows are reported. Roughly half of them are blank (no activity since last week)
You don't need a vLookup() formula for this. A simple SumProduct() formula will help you :) See the Snapshot for an example
FORMULA
=SUMPRODUCT((A2:A15="AAA")*(B2:B15="Dollar")*(C2:F15))
SNAPSHOT
Do let me know if this is not what you wanted?
HTH
Sid
To find a value in Excel based on both a column and row value, you will need to use both a vlookup and a match function.
=VLOOKUP($A10,$A$1:$E$6,MATCH($B10,$A$1:$E$1,0),0)
Have a look at the example picture below.
![Example for Lookup & Match Formula][1]
http://pzy.be/v/2/LookupMatch.jpg
B##la