+ Reply to Thread
Results 1 to 14 of 14

Formula for counting the amount of data cells with multiple criteria

  1. #1
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Question Formula for counting the amount of data cells with multiple criteria

    I have a pivot table in which id-number is in key position. I need the right formula for getting out the # of transactions (differ from 0) for each particular id in a single cell. Each row presents a single transaction and there may be multiple transactions for the same id during each year. The sample is pretty small and therefore number of cases is slightly reduced, but I hope you get it. Having been trying it for several hours now with getting error messages for the formula, your help would be highly appreciated.

    Small sample file attached describing the problem, please take a look.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Re: Formula for counting the amount of data cells with multiple criteria

    So far the closest I've had is by the following formula:
    =IF(COUNTIF(A$2:A2;A2)=1;COUNTIF(Table1[[2008]:[2016]];">0");"")
    which gives me the amount of all transactions regardless the ID. (I have been using word in finnish, so some of the punctuation marks may vary.)
    So from here I need the categorized amount for each particular ID.

  3. #3
    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,926

    Re: Formula for counting the amount of data cells with multiple criteria

    What would some sample answers look like?

    This part concerns/confuses me...
    I need the right formula for getting out the # of transactions (differ from 0) for each particular id in a single cell.
    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

  4. #4
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Re: Formula for counting the amount of data cells with multiple criteria

    Hi, just replied my best-so-far formula, does it bring any light on what I'm looking for? Sorry for my bad english. :P

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

    Re: Formula for counting the amount of data cells with multiple criteria

    Do the numbers that fall within each year count as a transaction? E.g. ID-Number 2 had 82 transactions in 2009? Or is it represented such as ID-Number 2 had one transaction in 2009, and 2 transactions in 2011?
    Spread the love, add to the Rep

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

  6. #6
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Re: Formula for counting the amount of data cells with multiple criteria

    Hi,
    each row counts as one transaction, sorry for being unclear. In the formula I attached in previous post you may be needed to change the semi-colons with commas to get it work in english excel.

  7. #7
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Re: Formula for counting the amount of data cells with multiple criteria

    Also, only by counting how many times the ID appear is not admissable here, because in the "real pivot" I have there are also rows that does not have transactions. That's why I need the amount counted throughout the years.
    Another thing that would help is the amount of years in which there are transactions for each person (each year counted max. once), which needs to be counted similarly as the first problem after it is solved somehow.
    Last edited by jt93; 03-02-2017 at 11:33 AM.

  8. #8
    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,926

    Re: Formula for counting the amount of data cells with multiple criteria

    You need to show - in your file - what your answers would look like. Enter them manually if needed, so we know exactly what you want

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

    Re: Formula for counting the amount of data cells with multiple criteria

    Dibbins may have a better solution down the line, but I'm still not sure if I'm understanding your question. If I did interpret it correctly, are you definitely attached to the current setup? I attached an example workbook with a second sheet detailing how I interpreted your request, and how I would have tried to setup a table.

    Otherwise, re-attaching your example workbook with how you hope to have the output look may be more beneficial for us.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Re: Formula for counting the amount of data cells with multiple criteria

    Thanks for your effort.
    Here is a new attachment, hopefully it brings some light what I'm trying to get. As mentioned earlier, just counting the amount of each ID is not appropriate here because of the bigger data sheet I'm working with.
    Just ask if I'm still too difficult to understand.
    BR, jt93
    Attached Files Attached Files

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

    Re: Formula for counting the amount of data cells with multiple criteria

    The first part of your question seems straightforward then. In L2 (or K2), enter:

    =IF(COUNTIF($A$2:A2,A2)=1,COUNTIF([id-number],A2),"")

    The second part is much more complicated based on how you have your table set up. I'll have to think on it, unless FDibbins can jump in.

  12. #12
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Re: Formula for counting the amount of data cells with multiple criteria

    Quote Originally Posted by mcmahobt View Post
    The first part of your question seems straightforward then. In L2 (or K2), enter:

    =IF(COUNTIF($A$2:A2,A2)=1,COUNTIF([id-number],A2),"")

    The second part is much more complicated based on how you have your table set up. I'll have to think on it, unless FDibbins can jump in.
    Thanks for your solution!
    It was not still quite what I was looking for; as I mentioned before,
    Also, only by counting how many times the ID appear is not admissable here, because in the "real pivot" I have there are also rows that does not have transactions. That's why I need the amount counted throughout the years.
    Therefore my sample file was not perfect in describing the situation. The actual table consists over 1k rows, so going through it manually would take ages. Hopefully there is a solution for both my inquiries.

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

    Re: Formula for counting the amount of data cells with multiple criteria

    Quote Originally Posted by jt93 View Post
    The actual table consists over 1k rows, so going through it manually would take ages.
    What are you "going through manually" regarding the formula I proposed? If you enter the formula, you can drag it down and have Excel autopopulate the cells.

    I also forged a solution to your second question, but it is by no means elegant. Hopefully someone else can chime in to clean it up, but in any case it is referenced below. I also attached the example workbook you provided that I am working out of.

    =IF(COUNTIFS(A$2:A2,A2)=1,IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2008]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2008]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2009]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2009]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2010]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2010]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2011]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2011]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2012]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2012]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2013]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2013]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2014]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2014]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2015]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2015]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2016]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2016]>0))),0),"")
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    09-27-2016
    Location
    Finland
    MS-Off Ver
    MS 2016
    Posts
    11

    Re: Formula for counting the amount of data cells with multiple criteria

    Quote Originally Posted by mcmahobt View Post
    What are you "going through manually" regarding the formula I proposed? If you enter the formula, you can drag it down and have Excel autopopulate the cells.

    I also forged a solution to your second question, but it is by no means elegant. Hopefully someone else can chime in to clean it up, but in any case it is referenced below. I also attached the example workbook you provided that I am working out of.

    =IF(COUNTIFS(A$2:A2,A2)=1,IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2008]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2008]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2009]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2009]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2010]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2010]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2011]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2011]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2012]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2012]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2013]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2013]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2014]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2014]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2015]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2015]>0))),0)+IFERROR(SUMPRODUCT(--(([id-number]=A2)*([2016]>0)))/SUMPRODUCT(--(([id-number]=A2)*([2016]>0))),0),"")
    Referring to your question, using the formula you provided me I would have to manually check the rows in which all the values are 0, so there is not a transaction at all. (This was the Achilles heel in my sample, there was no such an example row in it.) This formula anyways will save me a lot of time, thanks for helping!
    Have to try out that monster formula, thanks for processing it out! I will tell whether it helps or not.

+ 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] Counting cells that meet multiple single criteria as variable criteria
    By BillBasil in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-01-2016, 10:33 AM
  2. Counting data across multiple cells using a cell specific formula in countif
    By Brighteyed in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-24-2015, 10:04 PM
  3. Replies: 3
    Last Post: 03-01-2012, 06:17 AM
  4. counting cells with multiple criteria
    By keith6292 in forum Excel General
    Replies: 1
    Last Post: 11-19-2009, 07:37 PM
  5. Counting cells using multiple criteria
    By andrew.curley in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2006, 11:45 AM
  6. Counting Cells with multiple criteria.One criteria supporting wild
    By Azhar Saleem in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-12-2005, 07:06 AM
  7. [SOLVED] Counting Cells with multiple criteria.One criteria supporting wild
    By Azhar Arain in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-12-2005, 05:06 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