+ Reply to Thread
Results 1 to 12 of 12

Formula for conditional sum for distinct values

  1. #1
    Registered User
    Join Date
    10-19-2020
    Location
    India
    MS-Off Ver
    2007
    Posts
    6

    Formula for conditional sum for distinct values

    I have 3 columns in a table - From, To, and Amount. From and To field contains names. The logic is if a name features in the From section, it would mean money is paid by that person and if the name features in the To field, it would mean money is received. I wish to calculate sum total of receipts/ payments for each distinct name. Is this possible through a formula?
    I am attaching an excel sheet showing the input and the output that I wish to achieve.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,929

    Re: Formula for conditional sum for distinct values

    What is wrong with the formula you have already? Are you trying to generate the entire table or just the entries?

    Administrative Note:

    Members will tailor the solutions they offer to the version of Office (Excel) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,929

    Re: Formula for conditional sum for distinct values

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)

  4. #4
    Registered User
    Join Date
    10-19-2020
    Location
    India
    MS-Off Ver
    2007
    Posts
    6

    Re: Formula for conditional sum for distinct values

    Oh! I didn't know this. Let me check how to post cross post links

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,929

    Re: Formula for conditional sum for distinct values

    Post the link with one or two spaces in it, please. And then go and read the rules (which are the same in this respect on Chandoo, by the way): https://www.excelforum.com/forum-rul...rum-rules.html

  6. #6
    Registered User
    Join Date
    10-19-2020
    Location
    India
    MS-Off Ver
    2007
    Posts
    6

    Re: Formula for conditional sum for distinct values

    Nothing wrong but the list in the output table is static (and not dynamic) which means that one has to manually change the list everytime there is a new entry.
    Also, it would be more readable if I can just get the total values for each distinct name. I think this could be achieved with SQL - I will give this a try.

  7. #7
    Registered User
    Join Date
    10-19-2020
    Location
    India
    MS-Off Ver
    2007
    Posts
    6

    Re: Formula for conditional sum for distinct values

    Error message: You are not allowed to post any kinds of links, images or videos until you post a few times.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,929

    Re: Formula for conditional sum for distinct values

    READ what I said in post #5!!!

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,929

    Re: Formula for conditional sum for distinct values

    As you are clearly struggling, here is the required link: https://chandoo.org/forum/threads/fo...-values.47366/

    Please make sure that you do this yourself in future if you cross post again.

  10. #10
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: Formula for conditional sum for distinct values

    If you just want to get the totals, then you can use this formula (put it in cell G36 and then you can compare it with your totals on row 34 more easily):

    =SUMIF($C:$C,G$2,$D:$D)-SUMIF($B:$B,G$2,$D:$D)

    Copy across as required. Although most of the totals agree with yours, there are some discrepancies - I have not investigated why.

    Hope this helps.

    Pete

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: Formula for conditional sum for distinct values

    Your table is missing the following letters along row 2: C, A, W, G, T, and D.

    Also, you have 3 rows where the same letter appears in both columns B and C, i.e. rows 6, 20 and 22. Your formula doesn't account for these situations, so you need to change it in G3 to this:

    =IF($B3=G$2,-$D3,0) +IF($C3=G$2,$D3,0)

    then copy across and down as required.

    Hope this helps.

    Pete

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,929

    Re: Formula for conditional sum for distinct values

    You have said on the other forum that this is now resolved, so please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ 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. Conditional formatting not highlighting highest distinct values
    By StevieClem in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 11-25-2020, 10:48 AM
  2. Replies: 3
    Last Post: 11-22-2020, 08:58 AM
  3. Formula to extract unique values/distinct values in rows in excel
    By bjnockle in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-07-2020, 05:35 PM
  4. [SOLVED] Formula To Find Distinct Values With Criteria
    By masouder in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-18-2019, 06:27 PM
  5. [SOLVED] Formula that identifies distinct values in a list
    By tbrookes3 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-29-2016, 03:10 AM
  6. Replies: 3
    Last Post: 06-28-2016, 08:41 PM
  7. [SOLVED] Count Conditional Distinct Values
    By Gos-C in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-10-2013, 05:41 AM

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