VLOOKUP, MINIMUM to zero everytime?

srands

Board Regular
Joined
Jun 24, 2010
Messages
115
Hi I need to EDIT/REPLACE the following formula so that it counts from zero in each CATEGORY:

=LOOKUP(E4,{0,101,301,501,801},{"A","B","C","D","NEXT"})

At the moment the SPREADSHEET formula to replace the COLUMN F formula, WRONGLY counts 0 to 100, then 101 to 300, then 301 to 500, then 501 to 800, then 801 (Or something like that).

I WANT THE FORMULA TO COUNT AS FOLLOWS to CALC WHICH CATEGORY THE ITEMs ARE, PER ROW:
0 to 100, 0 to 300, 0 to 500, 0 to 800.

DESCRIPTION:
The formula needs to fill (As much possible, without going over the max), the CATEGORIES only in order of RANGE GROUPS (5 ranges, each with 4 different categories):
"A", then "B", then "C", then "D", then if possible count starts again at "A", etc.

TIER RANGES:

CATEGORY MIN MAX
A 0 100
B 0 300
C 0 500
D 0 800

DATA TABLE EG:
ROW 2, MISC ITEM, £50 X1 = £50, Running absolute total = £50, CATEGORY = A (Range A total so far = £50)

ROW 3, MISC ITEM, £30 X1 = £30, Running absolute total = £80, CATEGORY = A (Range A total so far = £80)

ROW 4, MISC ITEM, £30 X1 = £30, Running absolute total = £110, CATEGORY = B (Range B total so far = £30)

ROW 5, MISC ITEM, £50 X4 = £200, Running absolute total = £310, CATEGORY = B (Range B total so far = £230)

ROW 6, MISC ITEM, £80 X1 = £80, Running absolute total = £390, CATEGORY = C (Range c total so far = £80)


SEE SPREADSHEET IN PROGRESS

Cheers for your help as this conundrum has been troubling me for sometime!

Stephan



 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I barely follow what you are asking.

Wouldn't your category ranges be this?
A 0 100
B 101 400
C 401 900
D 901 1700

A is the first 100
B is the next 300
C is the next 500
D is the next 800

Formula
=LOOKUP(E4,{0,101,401,901,1701},{"A","B","C","D","NEXT"})
 
Upvote 0
After looking at your question closer and assuming my above answer is correct, you could use another column to calculate the upper limit for each Range-Category and then use that in the LOOKUP formula. In the example below, I used column I because it was empty.
Excel Workbook
EFGHIJKLM
1RUNNING TOTALCATEGORYRANGE GROUPRange\ Category cut offsRANGE GROUPSFROMTOCATEGORY
250A iRANGE GROUP i)0RANGE GROUP i)0100A i
380A iRANGE GROUP i)1010300B i
490A iRANGE GROUP i)4010500C i
5240B iRANGE GROUP i)9010800D i
6360B iRANGE GROUP i)1701RANGE GROUP ii)0100A ii
7480C iRANGE GROUP i)18010300B ii
8570C iRANGE GROUP i)21010500C ii
9660C iRANGE GROUP i)26010800D ii
10750C iRANGE GROUP i)3401RANGE GROUP iii)0100A iii
11840C iRANGE GROUP i)35010300B iii
12930D iRANGE GROUP i)38010500C iii
131020D iRANGE GROUP i)43010800D iii
141110D iRANGE GROUP i)5101RANGE GROUP iv)0100A iv
152310C iiRANGE GROUP ii)52010300B iv
163510B iiiRANGE GROUP iii)55010500C iv
174710D iiiRANGE GROUP iii)60010800D iv
185910C ivRANGE GROUP iv)6801RANGE GROUP v)0100A v
197110B vNEXT69010300B v
207110B vNEXT72010500C v
217110B vNEXT77010800D v
DATAlist & TIER RANGE TABLE
Cell Formulas
RangeFormula
F2=LOOKUP(E2,$I$2:$I$21,$M$2:$M$21)
F3=LOOKUP(E3,$I$2:$I$21,$M$2:$M$21)
F4=LOOKUP(E4,$I$2:$I$21,$M$2:$M$21)
F5=LOOKUP(E5,$I$2:$I$21,$M$2:$M$21)
F6=LOOKUP(E6,$I$2:$I$21,$M$2:$M$21)
F7=LOOKUP(E7,$I$2:$I$21,$M$2:$M$21)
F8=LOOKUP(E8,$I$2:$I$21,$M$2:$M$21)
F9=LOOKUP(E9,$I$2:$I$21,$M$2:$M$21)
F10=LOOKUP(E10,$I$2:$I$21,$M$2:$M$21)
F11=LOOKUP(E11,$I$2:$I$21,$M$2:$M$21)
F12=LOOKUP(E12,$I$2:$I$21,$M$2:$M$21)
F13=LOOKUP(E13,$I$2:$I$21,$M$2:$M$21)
F14=LOOKUP(E14,$I$2:$I$21,$M$2:$M$21)
F15=LOOKUP(E15,$I$2:$I$21,$M$2:$M$21)
F16=LOOKUP(E16,$I$2:$I$21,$M$2:$M$21)
F17=LOOKUP(E17,$I$2:$I$21,$M$2:$M$21)
F18=LOOKUP(E18,$I$2:$I$21,$M$2:$M$21)
F19=LOOKUP(E19,$I$2:$I$21,$M$2:$M$21)
F20=LOOKUP(E20,$I$2:$I$21,$M$2:$M$21)
F21=LOOKUP(E21,$I$2:$I$21,$M$2:$M$21)
I3=SUM($L$2:L2)+1
I4=SUM($L$2:L3)+1
I5=SUM($L$2:L4)+1
I6=SUM($L$2:L5)+1
I7=SUM($L$2:L6)+1
I8=SUM($L$2:L7)+1
I9=SUM($L$2:L8)+1
I10=SUM($L$2:L9)+1
I11=SUM($L$2:L10)+1
I12=SUM($L$2:L11)+1
I13=SUM($L$2:L12)+1
I14=SUM($L$2:L13)+1
I15=SUM($L$2:L14)+1
I16=SUM($L$2:L15)+1
I17=SUM($L$2:L16)+1
I18=SUM($L$2:L17)+1
I19=SUM($L$2:L18)+1
I20=SUM($L$2:L19)+1
I21=SUM($L$2:L20)+1
 
Upvote 0
Great! Many thanks AlphaFrog, your FORMULAs for COLUMN F & COLUMN I, work as intended. SPREADSHEET modified

I need your expertise to answer, a few other questions about how to incorporate the following:

~ In COLUMN N, the formula needs editing (If possible) to show the ACTUAL of how much £VALUE went into that CATEGORY per RANGE, if nothing, then 0.
EXAMPLE: If row 2 value was 320, then N2=0, N3=0, N4=320
So that the summary table (M25 to P25) can accurately add the number of CATEGORYs used per RANGE.

~ Following CATEGORIES may be the SAME value, or LESS value then the previous CATEGORY, what formula do I need to consider this? (Or in other words, the MAX values may NOT necessarily be in LOW to HIGH range value, or > then previous. COLUMN K ~ min & COLUMN L ~ max)
EXAMPLE: CAT A= 0 to 100, CAT B= 0 to 100, CAT C= 0 to 200, CAT D= 0 to 200.
For example if row 2 running total value was 99, and row 3 running total value was 197, then F2 = A i 1, then F3 = A i 2
Is it possible to have a formula to perform this complicated scenario calculation?

Many thanks

Stephan
 
Upvote 0
Put this in N2 and copy it down column N

=SUMIF(F:F,M2,E:E)

This will sum the values from column E if the values in column F match M2

This assumes each category in column M has a unique identifier as I have them in the example above e.g.; A i
 
Upvote 0
Thanks AlphaFrog, THANKS for formula, needed for Column D
=SUMIF(F:F,M2,D:D)

Q1. How to edit to check 2 columns?
As above but F:F, M2, G:G, J2, D:D

Q2. The formula in COLUMN F =LOOKUP(E2,$U$2:$U$21,$M$2:$M$21), sometimes miscalculates and exceeds the MAX of the specific category, can the formula(s) be edited so CATEGORIES aren't exceeded at all?
See an example of this error, the N4 SUMMARY of datatable D6:D9.

What formula do I need in COLUMN F and COLUMN U, to stop this error from happening?

Cheers

Stephan
 
Upvote 0
Q1:
The SUMPRODUCT formula you are currently using in column N is a two condition SUMIF-type formula. You can adapt it to do your SUMIF F:F, M2, G:G, J2, D:D

Q2:
The LOOKUP formula is not "miscalculating". Category C is getting an extra 100 because Category B stopped at 200 and not 300. When the category B running total is at 200, the next number in column D (D6) is then 200. This makes all of that 200 go to the next category C because it makes Category B over the limit. That's where the extra 100 is coming from.

If you make a lookup formula so that F6 is a B, then Category B will add up to 400 (100 over the limit).

So the question is how do you want to split up cell D6 when half of it is in Category B and half of it is in Category C ?
 
Upvote 0
Hi AlphaFrog, ok.

Q1. In formula how is that written?

Q2. Into CATEGORY C only, not any into CATEGORY B (D6 example).
The MAX in column L, to compare is like a glass that can't be over filled. Hence the formula is to start with the next CATEGORY, and leave the previous CATEGORY only partially filled.

Cheers for your help

Stephan.
 
Upvote 0
Re: VLOOKUP, remainder issue!

Hi AlphaFrog

Quick question, in my spreadsheet with your LOOKUP formula, how can the REMAINDER issues be resolved?
(Problems arise when maximum of categories not used within a range, then following categories exceed their maximum)
See M4 or M5 in most recent spreadsheet

OUR PREVIOUS THREADS RELEVANT TO "THIS" THREAD.

MY EMAIL:
The formula in COLUMN F =LOOKUP(E2,$U$2:$U$21,$M$2:$M$21), sometimes miscalculates and exceeds the MAX of the specific category, can the formula(s) be edited so CATEGORIES aren't exceeded at all?
YOUR EMAIL:
The LOOKUP formula is not "miscalculating". Category C is getting an extra 100 because Category B stopped at 200 and not 300. When the category B running total is at 200, the next number in column D (D6) is then 200. This makes all of that 200 go to the next category C because it makes Category B over the limit. That's where the extra 100 is coming from.

If you make a lookup formula so that F6 is a B, then Category B will add up to 400 (100 over the limit).

So the question is how do you want to split up cell D6 when half of it is in Category B and half of it is in Category C ?

MY EMAIL:
Into CATEGORY C only, not any into CATEGORY B (D6 example).
The MAX in column L, to compare is like a glass that can't be over filled. Hence the formula is to start with the next CATEGORY, and leave the previous CATEGORY only partially filled.

Cheers Stephan
 
Upvote 0
Excel Workbook
DEFGHIJKLM
1TOTALRUNNING TOTALCATEGORYRANGE GROUP*RANGE GROUPSFROM(MIN)TO(MAX)CATEGORY PER RANGE LETTER
2330330CRANGE GROUP i)*RANGE GROUP i)0100A0
3250580DRANGE GROUP i)*0300B0
4300880DRANGE GROUP i)*0500C330
52001080DRANGE GROUP i)*0800D750
63001380BRANGE GROUP ii)*RANGE GROUP ii)0100A0
72001580CRANGE GROUP ii)*0300B300
82001780CRANGE GROUP ii)*0500C500
91001880CRANGE GROUP ii)*0800D100
Sheet
Excel Workbook
TU
1formulas:Table, *Datalist CAT vlookup,
2RANGE GROUP i)0
3RANGE GROUP i)0
4RANGE GROUP i)0
5RANGE GROUP i)331
6RANGE GROUP ii)1081
7RANGE GROUP ii)1081
8RANGE GROUP ii)1381
9RANGE GROUP ii)1881
Sheet
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top