VLOKUP returns a wrong range - excel-formula

I have an excel data sheet like this:
I calculated the Assigned breakdown per week column using
=VLOOKUP(D2,table1,2,TRUE)
My problem is, it assigned 3 for the random number 0.75. But it should be 4 as I know.
Following is my column and row details.
Columns:- C,D,E,F
table1:- E2:F7 (Interval lower bound and Breakdown per week)
Assigned breakdown 1st data row:- 2(C2)
Why am I getting a wrong value for 0.75?

Related

Finding the last occupied cell using a formulae

This formulae "works", but it seems a bit long winded. Can anyone suggest an "easier" formulae. It returns the value in the 5th Column to a date in the 1st column which is called from a separate (and discrete) worksheet. If there is no data in the 5th column (because we haven't reached or passed that date), then the latest available data is called ($A$20, is the "calling date, on a current worksheet):-
IF(VLOOKUP($A$20,'[FTSE100.xlsx]Meteor Step Down
Plans'!$A$18:$E$2828,5)="",VLOOKUP(HLOOKUP(A20,'[FTSE100.xlsx]Meteor Step
Down Plans'!$A$18:$A$2628,MATCH(TRUE,INDEX(ISBLANK('[FTSE100.xlsx]Meteor
Step Down Plans'!$E$18:$E$2828),0,0),0)-1),'[FTSE100.xlsx]Meteor Step Down
Plans'!$A$18:$E$2828,5),VLOOKUP($A$20,'[FTSE100.xlsx]Meteor Step Down
Plans'!$A$18:$E$2828,5))
The formula is in a different workbook to the data. The formula is used to determine the last value in an array, the first column of which is a date range (01/01/2000 to 31/12/2027....say) The required data is in column 5. Entries may be up to date (i.e. the last entry was made today, therefore it will pickup todays value. The last entry may have been several days (weeks) ago, therefore it will pick up the last value in the designated column (column 5). I don't see why it can't go into a named range, as the array size is fixed. Does that help?
Thanks Ron, nearly there. That works beautifully for "missing" dates in the array. i.e. when Saturday and Sunday dates are missing, it finds the value (in column 5) of the previous Friday. However (and there is usually a "however"), if $A$20 is a date in advance of the date of the last data in the array i.e. column 5 is blank at that date, your formulae returns 0 (zero), instead of the data as at the last date that data has been entered. i.e. enter 02/04/2018 and your formulae returns 0, not the data at the last date available 28/02/2018. Is that a little more clear?? (Thank you anyway, for spending the time - I'm still trying to work out how your formulae works as it does. Is the "/" significant (other than being a "divide by" symbol, if so it's something I've never come across before? Regards...........Mike. P.S. The dates in the array (Column 1) are all in from 2016 to 2027 (excluding weekend and bank holidays), and are arranged in ascending order i.e. from 01/01/2016 to 31/12/2027
Ron - Sorry mate, buy I can't see a "second" formulae???
If I understand what you want to do correctly, (and that is hard to do since you give NO examples of your data, actual output or desired output), try:
=LOOKUP(2,1/((myDate>=A:A)*(LEN(A:A)>0)),E:E)
If it is the case that you have dates in column A and no entries in Column E, then you might have to do something like:
=LOOKUP(2,1/((myDate>=A:A)*(LEN(A:A)>0)*(LEN(E:E)>0)),E:E)
Of course, you will have to modify the cell references and named range to refer to the proper workbooks and cell.
Possibly something like:
=LOOKUP(2,1/(($A$20>='[FTSE100.xlsx]Meteor Step Down Plans'!$A$18:$E$2828)*(LEN('[FTSE100.xlsx]Meteor Step Down Plans'!$A$18:$E$2828)>0)),'[FTSE100.xlsx]Meteor Step Down Plans'!$E$18:$E$2828)
This should return the item from Column E that is either at or above the same row as myDate in Column A. If myDate does not exist in column A, it will match the nearest earlier date in Column A and return from that row in Column E.
In the second version of the formula, it also checks that there is an entry in Column E matching the column A date, and, if not, it will look above.

How do I count the number of unique customers sold to, per sales person?

To get the number of customers sold to by salesperson, my guess is I could either count the number of sales orders per salesperson per unique customer (i.e. not counting more than the first sale per customer)...
Or, count the number of unique customers per salesperson, where at least one sale is present.
I have done some research but I am still not sure which formula to use and/or how to write it. Here are some examples of what I found.
Excel sumproduct with countifs
count-unique-values-in excel-with-a-contition
count-unique-values-in-excel-with-two-conditions
excel-forumla-countifs-multiple-criteria-distinct-count
Image of my Excel File
Link to my Excel Example File
The most efficient formula AFAIK is with FREQUENCY function, similar to my formula suggestion in your third link "count unique values in excel with 2 conditions" i.e. this formula in D10
=SUM(IF(FREQUENCY(IF(B$16:B$21=B10,IF(E$16:E$21>0,MATCH(C$16:C$21,C$16:C$21,0))),ROW(C$16:C$21)-ROW(C$16)+1),1))
confirmed with CTRL+SHIFT+ENTER and copied down to D11
If you want it to work with filtered data try this version
=SUM(IF(FREQUENCY(IF(B$16:B$21=B10,IF(SUBTOTAL(9,OFFSET(E$16:E$21,ROW(E$16:E$21)-ROW(E$16),0,1)),MATCH(C$16:C$21,C$16:C$21,0))),ROW(C$16:C$21)-ROW(C$16)+1),1))
Explanation:
The MATCH function is the crucial part, that will return the same relative row number for repeated values. For your data MATCH function returns the following array:
{1;2;3;3;5;6}
Notice that the repeated 3 corresponds to your repeated customer Smith
The internal IF function returns the MATCH values only for rows where B10 matches (i.e. correct salesperson) and column E > 0 (there's a sale) so for your data the above array becomes this:
{1;2;3;3;FALSE;FALSE}
The first four values are the same as above because those 4 rows match salesman and have sales value > 0, rows 5 and 6 are FALSE because one or both conditions is FALSE
So, for our unique count we need to count the number of different numbers in that array (3)
FREQUENCY does that by assigning that “data array” to the “bins array” returned by
ROW(C$16:C$21)-ROW(C$16)+1
…. which evaluates to the following: {1;2;3;4;5;6}
So when the above data array is distributed into the bins (see FREQUENCY function for help on how this happens) you get this array, finally from FREQUENCY
{1;1;2;0;0;0;0}
[bin 1 gets 1 number, bin 2 gets 1 number but bin 3 gets 2 (the 2 threes)]
Now the external IF function assigns 1 to every non-zero value in that array, and SUM sums those 1s so the result is 3
Where A contains targeted salespersons initials (can be dragged down), B contains range of all initials, and C contains range of all amounts:
=SUMIF($B$4:$B$8,$A1,$C$4:$C$8)

Retrieve the cell reference of the first non-blank cell in a column

I have a data set (discrete monthly return series) with two dozen columns representing data series, c.100 rows representing month-end time-series. The data in the set represents the monthly performance of each data set.
Each series has run for a different length of time and is updated to a different length of time.
My conundrum is; I am looking to find, for each series, the dates of both the earliest data point and the most recent data point. I was hoping to do this by way of referencing the row headers (date) in column A. To do this I would need to know the row number of the earliest data point.
I can get the value of the earliest data point using a CSE IndexMatch, but what I really need is the reference.
EDIT
Tom, this is the data set;
As you can see, each data set starts (and finishes) at a different date.
In a summary sheet I am putting the date range for which each respective data series has data, that is why I need the row value (so that I can lookup the dates).
So your formula was fine, you just needed to MATCH in column G and INDEX into column A:-
=INDEX('Discrete Monthly Returns'!A3:A1048576,MATCH(FALSE,ISBLANK('Discrete Monthly Returns'!G3:G1048576),0))
I appreciate that you would want the start date to appear somewhere else, but this is just an illustration of how to use the formula
This example teaches you how to find the cell address of the maximum value in a column.
First, we use the MAX function to find the maximum value in column A.
Second, we use the MATCH function to find the row number of the maximum value.
Explanation: the MATCH function reduces to =MATCH(12,A:A,0), 7. The MATCH function returns the position of the maximum value in column A. Set the third argument to 0 to return an exact match.
Finally, we use the ADDRESS function to return the cell address.
Explanation: the ADDRESS function reduces to =ADDRESS(7,1), $A$7. The first argument specifies the row number. The second argument specifies the column number.
http://www.excel-easy.com/examples/locate-maximum-value.html
The answer is copy-paste work from the above link, but pasted here as reference.

How to find row at which summed total is greater than a certain amount?

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.

Excel pivot table calculated fields - referring to other dimensions in equation?

I'm struggling to find much useful documentation on Excel 2013 pivot table calculated fields.
My pivot table is fairly simple. I have a 'Company' dimensions as rows (e.g. 'A', 'B' etc) and calendar weeks as columns ('1' --> '52'). The value in the grid shows a date based status value. For example, for Company 'A' there are date based state source rows that are shown under 'week 6', 'week 14' and so on.
What I'm trying to do is inject a value into this pivot table to replace blank/null values. For instance, for Company 'A' there are no values for weeks 7 thru 13. In this case I want to inject a calculated field that looks for the last known value for Company 'A' and then uses that last know value. In this case the calculation for week 7 would detect that the value is null and find the last non-null value (week 6) and use that. The equation might be something like:
derived state = if(State=0, if(previous non null value > 0, previous non null value,0),0)
However, I can't find any docs that explain how to set up an equation that uses multiple dimension references and uses some form of lag or last known value finder function.
Any suggestions?
Thanks in advance!
One workaround is to fill in your null values. Then use the new data as the source for your pivot table. Below is a method of "copying" your data without modifying the original.
If this is your source data starting in cell A1:
1 2 3 4 5
1/1/2014 1/8/2014 1/15/2014 1/22/2014 1/29/2014
1/2/2014 1/9/2014 1/16/2014 1/23/2014 1/30/2014
1/3/2014 1/10/2014 1/17/2014
1/4/2014 1/11/2014 1/18/2014
this formula in cell F2 and pasted across will fill in your blank cells in for week 4 and 5.
=IF(A2<>"",A2,MAX(OFFSET(A2,0,-1*(A$1-1)):A2))
Step by step through the formula
check that A2 is not blank
if it isn't blank, copy the value in A2
if it is blank, choose the max (most recent) date from that row
the max should suffice for getting the last non-null value if the week columns are chronologically ordered

Resources