+ Reply to Thread
Results 1 to 18 of 18

Sumproduct - adding additional elements

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Sumproduct - adding additional elements

    Hi,

    I need some help adding additional conditions to a sumproduct formula please.

    Currently I have in cell L8:
    =SUMPRODUCT((LEN('Journal Data'!C7:$C$107)=0)*('Journal Data'!$DB$7:$DB$107))

    But I need to add;

    A match with column J on the “Validity check” sheet with column G with the “Journal Data sheet” . There should only be two matches so if it isn’t “ES (NC)” or “Leisure (NC)” then it needs to be classed as other.

    Then I need to add
    A match with column K on the “Validity check” sheet with row 3 with the “Journal Data sheet”

    Can anyone help please?

    The cell range: L8:L37 should tie back to that of Cell F10

    I have attached a sample
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Sumproduct - adding additional elements

    What are you trying to accomplish by your LEN() statement? Is it to just pull values that aren't zero? Why not just reference the range 'Journal Data'!C7:$C$107 and pull values that <>0? Same with cell F9.

    Along with this, your value for F8 seems excessive. Why do a lookup when you could reference the total column cell directly? Or do a MAX() on column DB to find the max value?
    Last edited by mcmahobt; 02-18-2015 at 11:51 AM.
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Sumproduct - adding additional elements

    Hi, I have always used: =LOOKUP(9.99999999999999E+307,'Journal Data'!DB:DB) to find the last row - no idea how to do it any other way.

    In terms of the LEN() formula I used it for all entries that are not zero. I can not use <>0 as this didnt give me the correct results

  4. #4
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Sumproduct - adding additional elements

    Hello
    I have finally figured out a formula
    L8 =SUMPRODUCT((OFFSET('Journal Data'!$L$7:$DA$107,0,MATCH(K8,'Journal Data'!$L$3:$DA$3,0)-1,101,MAX((INDEX(MAX(('Journal Data'!$L$3:$DA$3=K8)*(COLUMN($L:$DA))),0,0))-(MATCH(K8,'Journal Data'!$A$3:$DA$3,0)-1))))*(J7='Journal Data'!$G$7:$G$107))

    I was unable to incorporate the "others" criteria
    But please do check this formula....i think this is one of the most complex formula I have ever made....lol
    Hope this helps!!
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  5. #5
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Sumproduct - adding additional elements

    Just so I am able to understand what is happening here, I get how F8 is calculated (although, this could be simplified with a simple MAX('Journal Data'!DB:DB)), but what is F9 doing? I am assuming it is summing the values in column DB in Journal Data that corresponds to a value (not a blank) within the same row in column C of the same sheet.

    If this is correct, why not use <>"" (is not blank) vs. LEN()>0? It seems the results from F9 are incorrect upon inspection.

  6. #6
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Sumproduct - adding additional elements

    yes mcmahobt is correct... it seems that you are making problems complex....max in F8 and <>"" instead of len() would be a much better option

  7. #7
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Sumproduct - adding additional elements

    @Mcmahobt, the reason why it can not use <>"" is because in my main model I use a lookup where if false return "" and therefore it is not blank. So to get around this I use the length formula where so it avoids counting the blanks ("")

    @sourabhg98 , i apprechiate your efforts with this - I myself have spent ages on the formula. I couldnt get that to work though


    I have added an extra data set to show the expected results in columns O-Q on the "Validation Check" sheet

    When looking into this further I will also need a further match on the row 6 to match the word "cost"
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Sumproduct - adding additional elements

    Hi,

    Just to clarify the <>"" I have tested this in my main model (not the dummy test file uploaded on this post) and it can not be used. I need to use the Len() formula. Admittadly the dummy file is misleading as it shows the cells as blank. This is because I used a paste special but in the main model they are not blank, it appears blank but it is indeed "" (not blank)

  9. #9
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Sumproduct - adding additional elements

    You can still use SUMPRODUCT() and "<>" when cells contain "", you just have to use the "--" operator, and multiply by your value range essentially multiplying by zero. This is a speedier process than using LEN() for calculations regarding big data.

  10. #10
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Sumproduct - adding additional elements

    So currently I have this

    =SUMPRODUCT((LEN('Journal Data'!C7:$C$107)=0)*('Journal Data'!$DB$7:$DB$107))

    In simple terms I would also need:

    *('Journal Data'!$L$6:$DA$6="Cost")
    *('Journal Data'!$L$3:$DA$3='Validation Check'!K8)
    *('Journal Data'!$G$11:$G$107='Validation Check'!J8) (for "ES (NC)" and "Leisure (ES)" only if not class as only)

  11. #11
    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,969

    Re: Sumproduct - adding additional elements

    Im not sure how you can get the cell range: L8:L37 should tie back to that of Cell F10 when you are excluding row 11 (BU3)? unless that is covered by "Others"? In which case, all you need to to sum by Code (column K, row 3)and Journal col B <1?

    A few observations...
    on sheet Journal, you can change DB...
    =SUMPRODUCT(--(MOD((COLUMN(K7:DA7)-COLUMN(H1)),2)=0),K7:DA7)
    to...
    =SUMIF($L$6:$DA$6,DB$6,$L7:$DA7)
    copied down and across

    and seeing as DB will never be "", you can shorten ...
    B7=IF(AND(DB7<>"",C7<>""),MAX(B$6:B6)+1,"")
    to just...
    =IF(C7="","",MAX($B$6:B6)+1)

    On Validation sheet...
    F8=LOOKUP(9.99999999999999E+307,'Journal Data'!DB:DB)
    could be...
    =INDEX('Journal Data'!DB:DB,MATCH("Overall result",'Journal Data'!$G:$G,0))
    or just =DB108
    F9=SUMPRODUCT((LEN('Journal Data'!C7:$C$9651)>0)*('Journal Data'!$DB$7:$DB$9651))
    could be...
    =SUMIF('Journal Data'!$B$7:$B$106,">0",'Journal Data'!$DB$7:$DB$107)

    On Journal sheet...
    L8=SUMPRODUCT(('Journal Data'!$L$3:$DA$3='Validation Check'!$K8)*('Journal Data'!$L$6:$DA$6="Cost")*('Journal Data'!$G$7:$G$107='Validation Check'!J8)*('Journal Data'!$L$7:$DA$107))
    copied down
    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

  12. #12
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Sumproduct - adding additional elements

    Hi Ford

    Please Login or Register  to view this content.
    I think you are looking at Sheet 1 - ignore that, its only used to demostrate the expected results. The only 2 sheets in use are "Journal Data" and "Validation Check"

    I have made the change to B7, thanks!

    Does no one use: F8=LOOKUP(9.99999999999999E+307,'Journal Data'!DB:DB) to display the last row total? I have used it for a while but it seems people are against it?

    I have made the other changes you suggest.

    Now onto this one...
    Please Login or Register  to view this content.
    This is really close... It will never match with the word "other" as this doesnt appear on the "Journal Data" sheet. What I need it to do is basically if there isnt a code in column C of the sheet "Journal Data" and if it isnt either "Leisure (NC)" or "ES (NC)" then class it as other. Then sum it matching row 3 on the journal data sheet with column K of the validation sheet

    I hope that makes sense?
    Attached Files Attached Files

  13. #13
    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,969

    Re: Sumproduct - adding additional elements

    I think you are looking at Sheet 1 - ignore that, its only used to demostrate the expected results. The only 2 sheets in use are "Journal Data" and "Validation Check"
    I used your 1st D/L, thats the only 2 sheets there

    Does no one use: F8=LOOKUP(9.99999999999999E+307,'Journal Data'!DB:DB) to display the last row total? I have used it for a while but it seems people are against it?
    I wouldnt say that. If your are comfortable with something, use it - just keep in mind that there may be other, more efficient, ways of doing some things

    To try and simplify this, I added a helper column to JD sheet (I used F, use what you want, and it can be hidden), then copied this down...
    =IF(OR(G7="LEISURE (NC)",G7="ES (NC)"),G7,"Other")

    Then I changed the formula in VD to this, copied down...
    =SUMPRODUCT(('Journal Data'!$L$3:$DA$3='Validation Check'!$K8)*('Journal Data'!$L$6:$DA$6="Cost")*('Journal Data'!$F$7:$F$107='Validation Check'!J8)*('Journal Data'!$L$7:$DA$107))

  14. #14
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Sumproduct - adding additional elements

    Hi,

    Really apprechiate all your help with this Ford.

    Its even closer, nearly there...

    On the attached I have highlited the two cells where the error is highlighted.

    What I need is this:
    Please Login or Register  to view this content.
    Slightly amended to include the element where column C on the Journal Data tab must be blank. If it includes a wbs code then I need it to be excluded as in this analysis I am analysing the costs which have no WBS code.
    Attached Files Attached Files

  15. #15
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Sumproduct - adding additional elements

    Hello
    Use these formulas

    F7 =IF(C7="",IF(OR(G7="LEISURE (NC)",G7="ES (NC)"),G7,"Other"),"")
    and copy down

    L8 ==SUMPRODUCT(('Journal Data'!$L$3:$DA$3=$K8)*('Journal Data'!$L$6:$DA$6="Cost")*('Journal Data'!$F$7:$F$107=J8)*('Journal Data'!$L$7:$DA$107))
    and copy down

    Hope this helps!!

  16. #16
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Sumproduct - adding additional elements

    You can also give a try to this array formula which works without the helper column F

    =SUMPRODUCT(('Journal Data'!$L$3:$DA$3=$K8)*('Journal Data'!$L$6:$DA$6="Cost")*IF(J8="Other",('Journal Data'!$G$7:$G$107<>"Leisure (NC)")*('Journal Data'!$G$7:$G$107<>"ES (NC)"),('Journal Data'!$G$7:$G$107=J8))*('Journal Data'!$C$7:$C$107="")*('Journal Data'!$L$7:$DA$107))

    Hope this helps!!

  17. #17
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Sumproduct - adding additional elements

    Using both these methods the total is matching cell F10

  18. #18
    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,969

    Re: Sumproduct - adding additional elements

    Apologies, change the helper to this...
    =IF(ISNUMBER(B7),"",IF(OR(G7="LEISURE (NC)",G7="ES (NC)"),G7,"Other"))

+ 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] Using SUMPRODUCT with missing data elements
    By Jflann1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-15-2012, 02:34 PM
  2. [SOLVED] Syntax error adding additional UDT array elements
    By jdfjab in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2012, 03:19 PM
  3. [SOLVED] SumProduct? on 2 elements
    By overbomb in forum Excel General
    Replies: 3
    Last Post: 03-21-2012, 12:15 PM
  4. How to add additional elements to an array?
    By gnome_core in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2009, 10:42 AM
  5. sumproduct additional information for adding another criteria
    By Darlo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-20-2007, 11:30 AM

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