+ Reply to Thread
Results 1 to 7 of 7

Sumifs when there are several line items

  1. #1
    Registered User
    Join Date
    01-22-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    8

    Sumifs when there are several line items

    Hi there,

    I'm stuck and could really use some assistance on this.

    I am currently trying to sum between workbooks (for comparative purposes) using the same invoice number as criteria. This typically is not an issue, however the workbook I am writing the formula into has the invoice broken down into multiple line items, whereas the source workbook I am pulling the data from does not. For example:

    Formula workbook:
    Invoice 1 50
    Invoice 1 100
    Invoice 1 850

    Source workbook:
    Invoice 1 1,000

    Therefore every line with the sumif in the formula workbook returns 1,000 (total 3,000 for Invoice 1 in example above) which is obviously incorrect.

    What I am after is a formula, which when there are more than 1 line item for the same invoice (duplicates, as above), it will return the whole amount from the source workbook, and any future sums for the same invoice number will return zero. This will avoid getting 3,000 like in the example above.

    For example:

    Formula workbook:
    Invoice 1 50 1,000
    Invoice 1 150 0
    Invoice 1 850 0

    Is it possible to sumif the first criteria and when there are duplicates of the same criteria this returns nil? Once I can obtain the 1,000 I will add a column to split the 1,000 per the invoice percentages.

    Below is what I currently have:
    =IFERROR(IF(COUNTIF(AG:AG,AG106686)>1,IF(RIGHT(V106686,8)="Variance",0,IF(AC106686=0,0,SUMIF('Vendor Arrivals Pivot'!$H$2:$H$3974,'Combined VAT Report'!AG106686,'Vendor Arrivals Pivot'!$G$2:$G$3975)))*AC106686/IF(RIGHT(V106686,8)="Variance",0,IF(AC106686=0,0,SUMIF('Vendor Arrivals Pivot'!$H$2:$H$3974,'Combined VAT Report'!AG106686,'Vendor Arrivals Pivot'!$G$2:$G$3975))),IF(RIGHT(V106686,8)="Variance",0,IF(AC106686=0,0,SUMIF('Vendor Arrivals Pivot'!$H$2:$H$3974,'Combined VAT Report'!AG106686,'Vendor Arrivals Pivot'!$G$2:$G$3975)))),0)

    This works to the point that it will split the amount in the source workbook as a percentage of the line item. However, I have seen there are some cases where the amounts in the formula workbook for the same invoice are incorrect, and this creates an error.

    The end product would ideally be, the returned invoice value from the source workbook, which when dragged down would return nil for any other instances of that invoice.

    Unfortunately due to the nature of the formula workbook, I cannot remove duplicates, as they offer detail which is needed. I can also not upload any workbooks as this is sensitive data.

    I hope this is enough of an explanation for you.

    Many thanks in advance,
    Alex

  2. #2
    Registered User
    Join Date
    01-22-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    8

    Re: Sumifs when there are several line items

    Dummy workbook.xlsx Workbook added

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Sumifs when there are several line items

    E2 =if(countif($A$2:$A2,$A2)=1,VLookup($A2,'Source Data'!$A$2:$B$4,2,0),0) and drag down.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Registered User
    Join Date
    01-22-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    8
    Quote Originally Posted by oeldere View Post
    E2 =if(countif($A$2:$A2,$A2)=1,VLookup($A2,'Source Data'!$A$2:$B$4,2,0),0) and drag down.

    Thank you for your reply. However the source and formula data aren't in order so the vlookup doesn't return the correct data. Is there a way to use sumif as an alternative?

    Regards

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Sumifs when there are several line items

    g2 =if(countif($A$2:$A2,$A2)=1,sumif('Source Data'!$A$2:$A$4,'Formula Sheet'!A2,'Source Data'!$B$2:$B$4),0) and drag down.

  6. #6
    Registered User
    Join Date
    01-22-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    8
    Quote Originally Posted by oeldere View Post
    g2 =if(countif($A$2:$A2,$A2)=1,sumif('Source Data'!$A$2:$A$4,'Formula Sheet'!A2,'Source Data'!$B$2:$B$4),0) and drag down.
    This is fantastic, exactly what I needed. Thank you so much

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Sumifs when there are several line items

    You're welcome. We appreciate the feedback!

    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select 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 those who helped you reach a solution.

+ 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. How do I simplify this line graph -- over 200 line items??
    By klove in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-17-2015, 08:51 AM
  2. [SOLVED] sumifs excluding certain items
    By Tradesman in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 05-30-2014, 02:17 AM
  3. Multiple items on criteria for SUMIF (but not with SUMIFS)
    By Pullo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-16-2014, 01:17 PM
  4. Combining multiple line items into one line item based on column.
    By mguz018 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-20-2012, 07:22 PM
  5. Replies: 10
    Last Post: 03-01-2012, 01:20 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