+ Reply to Thread
Results 1 to 10 of 10

Running percentages with changing denominators

  1. #1
    Registered User
    Join Date
    01-24-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Post Running percentages with changing denominators

    Hi all,

    I have a list of SKUs that are tied to certain warehouses in our supply chain, and each of those SKUs has a sales forecast associated with it. We have 5 warehouses total, but not every SKU is in every warehouse. What I'm trying to figure out is how I can click and drag a formula that will give me the percent total of each SKU's forecast. So for the first SKU/Warehouse, it would be 5/5+6+4+6+7, and the next is 6/5+6+4+6+7, and so on. The problem I run into is when the SKU changes, and there is a different amount of warehouses, so a new denominator SUM layout is needed.

    I'm probably not explaining the best that it could be explained, but that's also why I can't find any answers on the internet.

    Here's what I'm looking at.

    SKU Warehouse Forecast
    19587 102 5
    19587 103 6
    19587 106 4
    19587 107 6
    19587 109 7
    23740 102 1
    23740 103 2
    23740 106 1
    23740 109 3
    170367 102 35
    170367 103 24
    170367 106 34

    I've been toying with OFFSET, but I can't get it to work. Any help is highly appreciated.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Running percentages with changing denominators

    Hi and welcome to the forum!

    Would it be possible for you to attach a workbook with a few examples, and, importantly, your desired results clearly outlined in each case?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    01-24-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Running percentages with changing denominators

    Sure, here's a quick example of what I'm looking for. I'm trying to figure out what percent of the total SKU forecast each warehouse holds, or what to expect sales-wise in each warehouse.
    Attached Files Attached Files

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Running percentages with changing denominators

    Thanks.

    And just to be clear, those are your desired results in column D? And that you'd prefer to have one formula which can be copied down to give all those results, rather than having to manually amend it for varying SKUs?

    Regards

  5. #5
    Registered User
    Join Date
    01-24-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Running percentages with changing denominators

    Yup! The manual entry works on something small, like that example, but doing it for thousands of rows...

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Running percentages with changing denominators

    Ok, then in D2 and copy down:

    =C2/SUM(INDEX(C$2:C$1000,MATCH(A2,A$2:A$1000,0)):INDEX(C$2:C$1000,LOOKUP(2,1/(A$2:A$1000=A2),ROW(A$2:A$1000)-MIN(ROW(A$2:A$1000))+1)))

    Regards

  7. #7
    Registered User
    Join Date
    01-24-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Running percentages with changing denominators

    That's like magic! Thanks! Is there any way you can explain the pieces, so I can understand it in the future? If not, I'll be happy just having the formula.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Running percentages with changing denominators

    Sure.

    We simply need to identify the range of summation in each case, whose starting and ending references will be the rows corresponding to the first and last occasions of the relevant SKU in column A respectively.

    So, for example, taking your formula in cell E4, to obtain the equivalent of your manually-entered range of C2:C6 we need to identify rows 2 and 6: the first of these is done by this part of the formula:

    INDEX(C$2:C$1000,MATCH(A4,A$2:A$1000,0))

    which, since MATCH, when used with the appropriate match_type (zero here) gives the relative position of the first occurrence of the lookup_value within the specified range, will resolve to:

    INDEX(C$2:C$1000,1)

    In its normal use, INDEX returns the cell value specified by a given row and column. However, one of the nice things about this function is that, properly coerced (as here), it can also return an actual cell reference. Hence, in this construction, the above is actually resolving to $C$2, and not the actual value (5) in that cell.

    The end range reference is identified by the second part:

    INDEX(C$2:C$1000,LOOKUP(2,1/(A$2:A$1000=A4),ROW(A$2:A$1000)-MIN(ROW(A$2:A$1000))+1))

    The trick with LOOKUP and reciprocation (the "1/" part) is a good one for finding the last occurrence of a value which meets certain criteria within a range. Since this function can operate on an array, this part:

    (A$2:A$1000=A4)

    returns a series of TRUE/FALSE responses to the test of which of those cell values is equal to the value in A4: in your example, the first few returns would be:

    {TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;,,,}

    The clever bit is that, when properly coerced (by e.g. any mathematical operation), Boolean TRUE/FALSE values are converted into their numerical equivalent (TRUE=1, FALSE=0), so that, for example, TRUE*TRUE = 1*1 = 1, TRUE*FALSE = 1*0 = 0, FALSE*TRUE = 0*1 = 0 and FALSE*FALSE = 0*0 = 0, we also have:

    1/TRUE = 1/1 = 1 and 1/FALSE = 1/0 = #DIV/0!

    so 1/(A$2:A$1000=A4) will be (again, for the first few entries only):

    1/{TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;,,,}

    which is:

    {1;1;1;1;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;,,,}

    Since LOOKUP ignores errors and, if the lookup_value (2 here) is not found within the array, returns the value from the specified range (ROW(A$2:A$1000)-MIN(ROW(A$2:A$1000))+1, which I'll come to in a bit) whose relative position in that array corresponds to the last item in the array less than or equal to the lookup_value, in this case that value will be 5, the relative position of the last 1 in the array above.

    This means that the LOOKUP will now take the 5th element in the array generated by:

    ROW(A$2:A$1000)-MIN(ROW(A$2:A$1000))+1

    which is a common construction to generate an array of consecutive integers from 1 onwards, i.e., and again, taking just the first few terms:

    {1;2;3;4;5;6;7;8;9;10;11;12;...

    (You can verify for yourself if you like how this is resolved.)

    Hence, this part:

    LOOKUP(2,1/(A$2:A$1000=A5),ROW(A$2:A$1000)-MIN(ROW(A$2:A$1000))+1)

    has now finally resolved to 5 and so:

    INDEX(C$2:C$1000,LOOKUP(2,1/(A$2:A$1000=A5),ROW(A$2:A$1000)-MIN(ROW(A$2:A$1000))+1))

    will become simply $C$6 (as before), meaning that the whole formula now becomes:

    C5/SUM($C$2:$C$6)

    just as you had!

    Regards
    Last edited by XOR LX; 01-24-2014 at 02:28 PM.

  9. #9
    Registered User
    Join Date
    01-24-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Running percentages with changing denominators

    Awesome, thanks so much for the help!

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Running percentages with changing denominators

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Calculating commissions with varying percentages based on running total
    By morgan74 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-05-2013, 01:04 AM
  2. Running total on percentages in Pivot table
    By Wayne Dunlop in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-13-2012, 03:46 AM
  3. Changing an exsisting chart to percentages.
    By Lorna B in forum Excel General
    Replies: 6
    Last Post: 03-08-2012, 08:33 AM
  4. Changing percentages based on text value
    By jar546 in forum Excel General
    Replies: 2
    Last Post: 04-22-2010, 08:19 PM
  5. changing prices in multiple colunms based percentages
    By MCOATES177@YAHOO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2006, 05:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1