+ Reply to Thread
Results 1 to 14 of 14

dynamic sum formula

  1. #1
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    dynamic sum formula

    Hi

    See attached file please. In col H rows 3-6 I have done a manual sum of eggs , bread and cheese for store 1,2 and 3.
    I would like this to be done automatically via a formula. So formula would need to recognise which store in col b want total for i.e.
    store1, store2 or store3 and then sum up the figures, for the store in colC and record the total for respective store for in colH.

    Note for store3, I have on purpose left out milk from the sum for store3 (80) to indicate the problem I have at the moment.
    Which is when items are added or taken away from a store I have to adjust the formula manually, to account for the extra , in this case milk ,
    so correct total for store3 is 135.
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: dynamic sum formula

    Are you set on how you have the data laid out? If you change the layout a bit, this will be simple using SUMIFS()
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: dynamic sum formula

    One way ...
    Define name manager Store1 in refers to enter formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and in cell "H3" formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Same for store2 & store3 (change range accordingly)


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,182

    Re: dynamic sum formula

    See the attached with changed layout:

    =SUMPRODUCT(($C$6:$E$9)*($C$5:$E$5=$G3))


    Think very carefully about organising your data.
    Attached Files Attached Files

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: dynamic sum formula

    or
    h2=SUMPRODUCT((LOOKUP(ROW($B$5:$B$21),ROW($C$5:$C$21)/($C$5:$C$21=""),$B$5:$B$21)=$G3)*($C$5:$C$21))
    Try this and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: dynamic sum formula

    Your data layout is horrible, as pointed out... it would be better to use reorganised data. However, it is possible that you are stuck with that layout. if so: use this (with a minimal change in layout - addition of a term at the end of the data)

    =IFERROR(SUM(INDEX($C$5:$C$25,MATCH(G3,$B$5:$B$25,0)):INDEX($C$5:$C$25,MATCH(G4,$B$5:$B$25,0))),"")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  7. #7
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    Re: dynamic sum formula

    Quote Originally Posted by JohnTopley View Post
    See the attached with changed layout:

    =SUMPRODUCT(($C$6:$E$9)*($C$5:$E$5=$G3))


    Think very carefully about organising your data.
    Hi,

    that worked great, and better organisation of data. Many Thanks.

  8. #8
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    Re: dynamic sum formula

    Quote Originally Posted by FDibbins View Post
    Are you set on how you have the data laid out? If you change the layout a bit, this will be simple using SUMIFS()
    Thank you for response. No data layout is not set. Please show how using sumifs.

  9. #9
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    Re: dynamic sum formula

    Quote Originally Posted by avk View Post
    One way ...
    Define name manager Store1 in refers to enter formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and in cell "H3" formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Same for store2 & store3 (change range accordingly)
    Thanks good idea

  10. #10
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    Re: dynamic sum formula

    Quote Originally Posted by Glenn Kennedy View Post
    Your data layout is horrible, as pointed out... it would be better to use reorganised data. However, it is possible that you are stuck with that layout. if so: use this (with a minimal change in layout - addition of a term at the end of the data)

    =IFERROR(SUM(INDEX($C$5:$C$25,MATCH(G3,$B$5:$B$25,0)):INDEX($C$5:$C$25,MATCH(G4,$B$5:$B$25,0))),"")
    Thank you. I see answer is correct but could you please explain where in the index match it knows only to count for store1 eggs bread cheese then store2 etc?

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: dynamic sum formula

    This bit does that:

    MATCH(G3,$B$5:$B$25,0)) looks for the name "store1" in column B and the INDEX portion (INDEX($C$5:$C$25) returns the corresponding value in column C. Excel then sums column C from there until it finds a match in column B for store2 - MATCH(G4,$B$5:$B$25,0).

    The term end was added simply to provide a stopping point for summing the data for the last store in the list.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  12. #12
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    Re: dynamic sum formula

    Quote Originally Posted by nflsales View Post
    or
    h2=SUMPRODUCT((LOOKUP(ROW($B$5:$B$21),ROW($C$5:$C$21)/($C$5:$C$21=""),$B$5:$B$21)=$G3)*($C$5:$C$21))
    Try this and copy towards down
    could you please give some notes as to how the logic in formula is working

  13. #13
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    Re: dynamic sum formula

    Quote Originally Posted by Glenn Kennedy View Post
    This bit does that:

    MATCH(G3,$B$5:$B$25,0)) looks for the name "store1" in column B and the INDEX portion (INDEX($C$5:$C$25) returns the corresponding value in column C. Excel then sums column C from there until it finds a match in column B for store2 - MATCH(G4,$B$5:$B$25,0).

    The term end was added simply to provide a stopping point for summing the data for the last store in the list.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.
    many thanks for explanation I have added to rep. and clicked solved thread

  14. #14
    Forum Contributor
    Join Date
    03-02-2017
    Location
    uk
    MS-Off Ver
    2010
    Posts
    104

    Re: dynamic sum formula

    Quote Originally Posted by Glenn Kennedy View Post
    This bit does that:

    MATCH(G3,$B$5:$B$25,0)) looks for the name "store1" in column B and the INDEX portion (INDEX($C$5:$C$25) returns the corresponding value in column C. Excel then sums column C from there until it finds a match in column B for store2 - MATCH(G4,$B$5:$B$25,0).

    The term end was added simply to provide a stopping point for summing the data for the last store in the list.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.
    Thanks but I still do not see how you reach the (correct) total of 66 for store1. Also why is formula also referencing G4 (store2) when I am looking for total for store1 in cell I3? And same for cell I4 why are two stores being referenced (store2 and3) when getting total for store2 in I4?
    Last edited by eggs; 04-26-2017 at 04:07 AM.

+ 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] dynamic chart values formula with dynamic starting point
    By Kramxel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-24-2015, 03:30 AM
  2. [SOLVED] Dynamic formula, (copy from dynamic formula and ignore 0)
    By Kartoffelmos in forum Excel Formulas & Functions
    Replies: 42
    Last Post: 10-20-2014, 09:14 AM
  3. VBA - Updating Dynamic Line Chart & Inserting Dynamic Formula
    By bruno08102013 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-09-2014, 10:10 AM
  4. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  5. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  6. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  7. Replies: 2
    Last Post: 02-02-2006, 04:10 PM

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