I'm trying to calculate a daily count, given that I have current date, city, and total count.
For each row, I imagine [city's current total] - [the previous total for that city] = the daily count.
Not all cities exist in every date. The number of rows may vary between dates for each city.
I've tried INDEX and MATCH with VLOOKUP, but don't Excel functions well enough.
I'm familiar with arrays, but can't figure how to pluck the UBOUND and UBOUND-1 counts based on the date + city criteria. Ideas?
In E2204 put:
=D2204-INDEX(D:D,AGGREGATE(14,7,ROW($D$1:$D2203)/($C$1:$C2203=C2204),1))
OR if one has the formula XLOOKUP:
=D2204 - XLOOKUP(C2204,$C$1:$C2203,$D$1:$D2203,0,0,-1)
Related
I have the opposite query for this question:
Excel - Lookup to return multiple values in between date range
The solution is given for the above query in the following link also:
https://www.get-digital-help.com/2009/12/13/formula-for-matching-a-date-within-a-date-range-in-excel/
But my query is that for multiple date ranges, how do I find the total bookings of a single date.
I wish to build a calendar which will allow me to work out how many booking I have for a certain day. All the bookings are for 1 or more items and I want the total items which will be there on a single day, across a date calendar range.
On the calendar on the right side, I wish to add the total items which will be staying over during that specified date.
So, in the example, on the 26th December, a total of 6 items will be there. And for 5th December there is only 1, while for 1st December there are no items.
Would like to have these numbers in the calendar on the right.
I have tried using VLOOKUP, LOOKUP, INDEX and MATCH.
Also, tried the SUMPRODUCT mentioned, but those seem to give a single range and number for that range, but not the multiple values across a date range.
https://chandoo.org/wp/range-lookup-excel/
Formulae I tried are, for the 26th December date are:
=(LOOKUP(H10,((Table1[Date From]):(Table1[Date To])),Table1[Items from]))
=SUMIF(Table1[Item],(LOOKUP(2,1/(Table1[Date From]<=H10)/(Table1[Date To]>=H10))))
=INDEX(Table1[Item from],MATCH(H10,LOOKUP(H10,Table1[[Date From]:[Date To]])))
For Dec 26th (and keeping your original structure)
=SUMIFS(Bookings[[Items]:[Items]],Bookings[[Date From]:[Date From]],"<=" &H10,Bookings[[Date To]:[Date To]],">="&H10)
Note that I used the absolute address structured reference form so you can at least fill/drag across a row, without changing the columns from the table.
If you want to make things even easier, you can replace the H10 reference with a computed reference, but at the cost of using OFFSET which is a volatile function.
=SUMIFS(Bookings[[Items]:[Items]],Bookings[[Date From]:[Date From]],"<=" &OFFSET(H$1,ROW()-2,0),Bookings[[Date To]:[Date To]],">="&OFFSET(H$1,ROW()-2,0))
You might also be able to construct a computed cell reference using the INDEX function, which would be non-volatile.
Updated answer with array formulas
Sorry for not understanding your first request.
You can use the following array formula in a "single cell"
{= SUM( IF( (E2 >=$B$2:$B$8 ) * (E2<=$C$2:$C$8) ; $A$2:$A$8 ; 0 ))}
Where column e contains the target dates, columns a, b and c contain items, from and to.
This formula is expansible and copiable to other cells where e2 will be relatively changed for each target date. This is easily adaptable to your month table. Put the formula below the first date, then expand horizontally and copy/paste to the other rows.
See picture:
Old answer
Create a separate cell with your target date. Suppose $e$1.
Create on e2 this formula: =if( and( $e$1 >= c2 ; $e$1 <= d2 ); a2; 0)
Expand it and sum at the bottom.
Sorry for my formulas in Portuguese in the image (se = if ; e = and):
I have a list of data with 200k plus lines. I need to search for the next order date before a certain date, that matches an ID number in excel. I know I can use index match to find the next date before a given date, but how would I do that when I need the ID numbers to match a given ID? I have attached a sample format of my data I am searching in. The problem is also that I am not search by a range of dates, I need the next date before a certain date. There are multiple dates before a given date, I need to just pull the one before.
Index match formula to find the next given date.
=INDEX(Orders!B:B, MATCH(MIN(ABS(Orders!B:B-F3)), ABS(Orders!B:B-F3), 0))
ID Date
1 7/22/2015
2 4/27/2016
3 7/6/2016
2 4/23/2016
Another way to state your requirement is to find the maximal date in B:B that is < F3 and has in A:A the ID specified in E3. This is exactly what the following formula does:
=AGGREGATE(14,6,Orders!B2:B999/(Orders!B2:B999<F3)/(Orders!A2:A999=E3),1)
AGGREGATE(14, ...., 1) get the max result in the given array
The divisions by the criteria will generate DIV!0 in the array entries that don't match the criteria
Parameter 6 instructs the function to ignore the error entries, including those divisions by 0
Notice that although this formula does not require CSE, it is array-based, so avoid using full-columns because they slow-it down. Choose a reasonable number of rows (i.e. A2:A999) that is sufficient to span your data.
I would like to find the row at which running summed value has reached a specified amount and several criteria have been met (similar to sumifs).
I can't just add a cumulative row, as suggested here:
Count rows until the sum value of the rows is greater than a value
....because I have other criteria to meet in the data, and therefore can't have a running total.
In the following dummy example, I'd like to find the date at which the "Design" project has spent or exceeded $30,000
A late answer, but one that doesn't use a Helper Column.
By using Matrix Multiplication (MMULT) on a TRANSPOSEd array of whether the Row is larger than itself and the list itself, we can produce an array of the Running Total.
MMULT(--(TRANSPOSE(ROW(D2:D21))<=ROW(D2:D21)), D2:D21)
If we shrink this to just the first 3 rows, to demonstrate, then you are making this calculation:
[[--(2<=2)][--(3<=2)][--(4<=2] [[10,000]
[--(2<=3)][--(3<=3)][--(4<=3] ∙ [ 8,000]
[--(2<=4)][--(3<=4)][--(4<=4]] [ 6,000]]
Which gives us this:
[[1][0][0] [[10,000] [[10,000]
[1][1][0] ∙ [ 8,000] = [18,000]
[1][1][1]] [ 6,000]] [24,000]]
We can then compare that against the target value as a condition and divide by the result to eliminate values with #DIV0! errors, and use AGGREGATE to get the smallest non-error value
=AGGREGATE(15, 6, Row(D2:D21) / (MMULT(--(TRANSPOSE(ROW(D2:D21))<=ROW(D2:D21)), D2:D21)<30000), 1)
This will give us the first row where the Running Total is >= $30,000
make a cumulative row, only adding up if column B equals 'Design'
If you want to be able to do a vlookup, you should make an extra column that checks if amount exceeded 30k, and then output anything that will be your key for the vlookup.
Ok, for anyone who is interested, here is what I ended up doing. I created a separate table that had all of my possible weeks (10/17, 10/24, 10/31, etc.) in one column, and corresponding sequential numbers in the next column. I ended up with 54 in my actual project.
Then, I ended up having to insert one column into my dataset for the purposes of looking up that "Week No", for each "Week" in all rows. Then on my other sheet where I was solving, I had a cell be my decision variable for the week #. I had another be my target $. I created a formula that took my target amount minus the SUMIFS for all of my criteria (Project, Name, etc.) with the last criteria being that the week number had to be "<=" & (decision cell). I then used Solver to minimize the output by changing the target week with constraints that the target week had to be integer, >=1, <=54, and that the output had to be >=0. That got me to the week prior to where the funding went negative. I then had a cell lookup that week number +1 on my weeks table to find the week at which my target amount would be met.
Sorry, had to explain it that way, vs. the actual formula, as my actual formula has a lot of SUMIFS criteria and cell references that wouldn't make any sense here.
We keep track of salaries using an excel file with a tab per month:
50 = regular salary
100 = regular salary for double shift
30, 60 etc. are exceptions that don´t need to be considered
Now my boss wants to know who worked how often considering the normal and double shifts only. so the result should be a list(table) like Bob 50*X, 100*Y, Bill 50*X, 100*Y
What would the syntax look like? It´s possible that while Bill is B1 in January it might be that he is C1.. in another month so the solution should use the header row to do a lookup.
In your example, the formula
=COUNTIF(B2:B7,50)
will return the number of instances of the data 50 in the range B2:B7.
In order to find the column corresponding to a specific employee you can use MATCH, (e.g.) MATCH("Bob",B1:C1,0) which finds the exact text Bob in the range B1:C1. Now you need to change the range in your COUNTIF function to correspond to the column for Bob, which you can do with OFFSET:
=COUNTIF(OFFSET($A$2,0,MATCH("Bob",$B$1:$C$1,0),6,1),50)
The number 6 in the above formula is the number of rows containing salary data - could that change? If so you could replace it with e.g. MATCH("Tot",$B2:$A99,0)-1 which will count how many rows there are from row B to the row containing Tot.
Look up the functions COUNTIF, MATCH and OFFSET in the Excel help for more detail on how to use them.
I have data with the entities date, name, price. I managed to get distinct categories in the Categories colume for each name with = LEFT(B2;FIND(" ";B2)). In fact I want to get for each categorie the summed up monthly prices per month.
My sheet:
I tried:
=SUMIF(B2:B6;LEFT(B2;FIND(" ";B2));C2:C6)
However, this formula returns 0 and also does not give me the prices per categorie and per month.
I really appreciate your help!!!
If you want a sum on each row which will sum for the category of the current row and the month of the current row you can use SUMIFS like this
=SUMIFS(C:C;E:E;E2;A:A;">"&EOMONTH(A2;-1);A:A;"<="&EOMONTH(A2;0))
SUMIFS requires Excel 2007 or later
=SUMIF(E:E,E2,C:C) will sum the categories for you
I think if you want to sum categories by date, you might want to use a Pivot Table or write a Macro
You can write a =sumif function with multiple criteria but I'm not sure how you would define the "date rage" for each new criteria