+ Reply to Thread
Results 1 to 13 of 13

Replace value by cell number in sumproduct function

  1. #1
    Registered User
    Join Date
    09-21-2018
    Location
    Hong Kong
    MS-Off Ver
    Office 365 version 16
    Posts
    17

    Replace value by cell number in sumproduct function

    Hi There,

    I am building a tiers pricing model with a rate that decrease depending on the number of hours commited. I have this formula using SUMPRODUCT that is working fine. However I would like to replace the numbers in the formula with cell so that when the cell number change I don't have to manually change the SUMPRODUCT formula. But when I do this I have error message poping up and don't seems to be able to link the cell to this formula

    =SUMPRODUCT(--(C16>{0,10,15,20,30,50,200,500,1000,2000}),--(C16-{0,10,15,20,30,50,200,500,1000,2000}),{800,-64,-54,-46,-40,-34,-30,-26,-23,-20})

    The first part of the formula is the range of hours
    (--(C16>{0,10,15,20,30,50,200,500,1000,2000}),--(C16-{0,10,15,20,30,50,200,500,1000,2000})

    I would like to simply replace each number with the cell where the number is

    The second part of the formula is the rate
    {800,-64,-54,-46,-40,-34,-30,-26,-23,-20})

    I would like to replace the number with the cell and the formula (ie : H4-H3)

    Thought appreciated

    Thanks!
    Attached Files Attached Files
    Last edited by DFHK; 09-24-2019 at 09:16 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 2019
    Posts
    16,514

    Re: Sumproduct

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

  3. #3
    Registered User
    Join Date
    09-21-2018
    Location
    Hong Kong
    MS-Off Ver
    Office 365 version 16
    Posts
    17

    Re: Replace value by cell number in sumproduct function

    Hi Alan,

    Thanks for the note. I have updated the title, please review and let me know if this is ok ... Thanks!

  4. #4
    Valued Forum Contributor
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    367

    Re: Replace value by cell number in sumproduct function

    I think this should work.
    =SUMPRODUCT(--(C16>C15:L15),--(C16-C15:L15),C14:L14)

  5. #5
    Registered User
    Join Date
    09-21-2018
    Location
    Hong Kong
    MS-Off Ver
    Office 365 version 16
    Posts
    17

    Re: Replace value by cell number in sumproduct function

    Not quite .... it does not output the right result ...

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2019 (Win 10 - Work) & 365 Subscription Insider (Win 10 - Home)
    Posts
    34,175

    Re: Replace value by cell number in sumproduct function

    Did you enter it using CTRL+SHIFT+ENTER (not just ENTER)?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  7. #7
    Registered User
    Join Date
    09-21-2018
    Location
    Hong Kong
    MS-Off Ver
    Office 365 version 16
    Posts
    17

    Re: Replace value by cell number in sumproduct function

    Quote Originally Posted by AliGW View Post
    Did you enter it using CTRL+SHIFT+ENTER (not just ENTER)?
    yes I have done that but the output is not right .... I am trying to upload the file

  8. #8
    Registered User
    Join Date
    09-21-2018
    Location
    Hong Kong
    MS-Off Ver
    Office 365 version 16
    Posts
    17

    Re: Replace value by cell number in sumproduct function

    I have attached the file ... please take a look

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2019 (Win 10 - Work) & 365 Subscription Insider (Win 10 - Home)
    Posts
    34,175

    Re: Replace value by cell number in sumproduct function

    So tell us what the output should be, please.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2019 (Win 10 - Work) & 365 Subscription Insider (Win 10 - Home)
    Posts
    34,175

    Re: Replace value by cell number in sumproduct function

    Maybe you need this:

    =INDEX($C$4:$C$13,MATCH(G2,$A$4:$A$13,1))

    and this:

    =INDEX($D$4:$D$13,MATCH(G2,$A$4:$A$13,1))

  11. #11
    Registered User
    Join Date
    09-21-2018
    Location
    Hong Kong
    MS-Off Ver
    Office 365 version 16
    Posts
    17

    Re: Replace value by cell number in sumproduct function

    Quote Originally Posted by Gregb11 View Post
    I think this should work.
    =SUMPRODUCT(--(C16>C15:L15),--(C16-C15:L15),C14:L14)
    Quote Originally Posted by AliGW View Post
    So tell us what the output should be, please.
    In this case, there is a range of hours with a rate attached to each range. The hours' range and rate are nonlinear. For example

    5 -10 hours ----- rate 1000
    11 - 15 hours --- rate 950
    16 - 20 hours --- rate 900
    21 -30 hours --- rate 800

    So if the order is 25 hours the rate will be calculated as follow

    10 hours X $1,000
    5 hours X $950
    5 hours X $900
    5 hours X $800

    Total: 23,250. That will be the correct output which my formula return. When using the proposed formula then the result is 29,000

  12. #12
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    409

    Re: Replace value by cell number in sumproduct function

    In your file, replace the "High", "Min Rate", and "Max Rate" headers with zeros, and try the following formulas:

    for Max Rate =SUMPRODUCT(--(G2>B3:B12),--(G2-B3:B12),ROUND(D4:D13-D3:D12,0))
    for Min Rate =SUMPRODUCT(--(G2>B3:B12),--(G2-B3:B12),ROUND(C4:C13-C3:C12,0))

    Those are normally-entered formulas -- no need to use Ctrl+Shift+Enter.

    You may need to play with rounding.

  13. #13
    Registered User
    Join Date
    09-21-2018
    Location
    Hong Kong
    MS-Off Ver
    Office 365 version 16
    Posts
    17

    Re: Replace value by cell number in sumproduct function

    Quote Originally Posted by Gregb11 View Post
    I think this should work.
    =SUMPRODUCT(--(C16>C15:L15),--(C16-C15:L15),C14:L14)
    Quote Originally Posted by Root_ View Post
    In your file, replace the "High", "Min Rate", and "Max Rate" headers with zeros, and try the following formulas:

    for Max Rate =SUMPRODUCT(--(G2>B3:B12),--(G2-B3:B12),ROUND(D4:D13-D3:D12,0))
    for Min Rate =SUMPRODUCT(--(G2>B3:B12),--(G2-B3:B12),ROUND(C4:C13-C3:C12,0))

    Those are normally-entered formulas -- no need to use Ctrl+Shift+Enter.

    You may need to play with rounding.
    Thanks root_ This works like a charm. However the rounding is creating some inaccurracy. How is the formula would like without the round dunction?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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