+ Reply to Thread
Results 1 to 31 of 31

Count if/Sum if/ or Sum product

  1. #1
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Count if/Sum if/ or Sum product

    Hi everyone,

    I have a question about a formula in excel 2007. People had gave a score to multiple questionnaires. The range is from 1 to 10.
    The scores per person are given in one row and the person are divided by age in columns.

    For example:

    18 years old
    person 1) 8 7 9 8 4 5
    Person 2) 3 5 6 7 8 9
    person 3) 3 5 6 9 9 10

    Range: A2 / C4
    20 years old
    person 1) 8 7 9 8 4 5
    Person 2) 3 5 6 7 8 9
    person 3) 3 5 6 9 9 10

    The Question: What's the formula to count how many times the scores occur together in a row, for example 7 and 8? And the range is fixed by age. For example the range for the formula 1 is A2 to C4 and the criteria are 7 and 8. So i want to count the criteria 7 and 8 for each row in range of A2 to C4.

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Count if/Sum if/ or Sum product

    can you put those data in a real workbook and provide some example of the expected results.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    Quote Originally Posted by vlady View Post
    can you put those data in a real workbook and provide some example of the expected results.
    I have attached the file Questionnaires.
    And the question is, how many times the scores per person correlate in the column Age?

    So for example: the first column the scores 7 and 8 correlate per person, 7 times in the first column.

  4. #4
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    try this in K2
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    drag down

    just change the "7" and/or "8" to whatever values you want to check

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  5. #5
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    or for easier modification, put first value in k2,second in l2
    then in m2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    drag M2 down

    -Edit-
    or in M2
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    drag down

    this will get rid of 0's between the groups

    Hope this helps
    Last edited by dredwolf; 11-21-2012 at 05:22 PM.

  6. #6
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    But it counts the 7 and 8's separate. And has to count them together. So in the first column the 7 and the 8 combines 2 times

  7. #7
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    okay, try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ( I have moved the criteria from L2 and K2 to L1 and K1 to allow a blank column to keep the criteria ranges the same size)

    Hope this helps

    -Edit-
    If the order they appear together is important, then get rid of one of the countifs', first one does "7" followed by "8", second one does "8" followed by "7"
    Last edited by dredwolf; 11-27-2012 at 08:30 PM.

  8. #8
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Isn't this possible? It gives a value error. Look at the bold sections of the formula.
    For example if the 7 is in first part of the the column a always have to check it and it takes a lot of time.

    Thnx

  9. #9
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    Quote Originally Posted by dredwolf View Post
    ( I have moved the criteria from L2 and K2 to L1 and K1 to allow a blank column to keep the criteria ranges the same size)
    this is Why you are getting the #VALUE error,the ranges of the conditions need to be the same size

    Hope that helps

  10. #10
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    But it isn't possible to use two the same ranges, is it? For example COUNTIFS(B2:J2,$K$1,B2:C2,$L$1)? That's why i still get a VALUE error while using the same range size.

  11. #11
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    Quote Originally Posted by Mverm0 View Post
    COUNTIFS(B2:J2,$K$1,B2:C2,$L$1)
    The Bold,Unlined,Red sections above are the ranges, and are not the same size, the first one encompasses 9 cells (B2,C2,D2,E2,F2,G2,H2,I2,J2), while the second encompasses only 2 cells (B2,C2), they both need the same cell count to be the same size

    Hope this helps

  12. #12
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    COUNTIFS(B2:J2,$K$1,B2:J2,$L$1)

    But if they are the same size and range you'll still get a value error. Because of the number 7 and 8 using the same cell. This isn't possible in this column/row and gives a value error. But what's the solution for the error?

  13. #13
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    I'm really not sure what you are asking, the formula in your last post is try to count values that are equal to k1{7} and equal to l1{8}, which it cannot be equal to both

    COUNTIFS(B2:J2,$K$1,C2:K2,$L$1) counts where the first cell (b2 say) is equal to k1, and the next cell(c2) is equal to l1

    if you wanted to count where b2 was between k1 and l1 you could use something like this countif(B2:J2,">"&K$1,B2:J2,"<"&$L$1)

  14. #14
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    Quote Originally Posted by dredwolf View Post
    I'm really not sure what you are asking, the formula in your last post is try to count values that are equal to k1{7} and equal to l1{8}, which it cannot be equal to both

    COUNTIFS(B2:J2,$K$1,C2:K2,$L$1) counts where the first cell (b2 say) is equal to k1, and the next cell(c2) is equal to l1

    if you wanted to count where b2 was between k1 and l1 you could use something like this countif(B2:J2,">"&K$1,B2:J2,"<"&$L$1)
    But what if i want to equal B2:J2 to 7 and B2:J2 to 8?

    B2 J2
    1 2 3 4 5 6
    4 3 6 7 8 9

    3 and 4 combines two times in this column.
    If i use your formula COUNTIFS(B2:J2,$K$1,C2:K2,$L$1) it will only combine once. Because it doesn't count the 4 in the second row.

  15. #15
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    check the attachment, it contains my original formula in column m, and this formula in column n, which is the correction you asked for
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    Look at the yellow outcomes. The combination "7 and 8" should be 1 in the bold sections, but it isn't.
    Attached Files Attached Files

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

    Re: Count if/Sum if/ or Sum product

    See the green cells.

    See if this is what you want.

    Dutch
    Please Login or Register  to view this content.
    Englisch
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by oeldere; 12-01-2012 at 11:12 AM.
    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.

  18. #18
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    So, basically, if there is any combination of 7 & 8, anywhere in the array, it gets a count of 1, if both numbers are not present it counts as 0 ?

    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag down
    Last edited by dredwolf; 12-01-2012 at 12:13 PM. Reason: forgot the formula

  19. #19
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    The difference is in the formula counts the combination "7 and 8" next to each other. But i want it to count the combination per row.

  20. #20
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    It gets a count of 1, if there's an combination. But i need to know how many combinations of 7 & 8 there are in the array.

  21. #21
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Count if/Sum if/ or Sum product

    oeldere post (#17) seems to accomplish what you are looking for, have you tried it?

  22. #22
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    Thnx. But if i want to calculate per row for the age group the different combinations?

    The best possibility is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    Re: Count if/Sum if/ or Sum product

    Have you tried my solution in #17?

  24. #24
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    It does work. Thank you for that.

    But if I now need to calculate the entire column. I will have to add all the rows individually. Is this the best option?
    Maar als ik nu het voor de hele column moet berekenen, dan moet ik het per rij optellen.

    For example:
    =MIN(countif($B2:J2,$K$1),countif($B2:J2,$L$1))+MIN(countif($B3:J3,$K$1),countif($B3:J3,$L$1)) etc.

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

    Re: Count if/Sum if/ or Sum product

    Please Login or Register  to view this content.
    Change the red value in the formula (e.g. k2), and drag the formula down.

  26. #26
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    I did that, but then it counts every combination possible in the column. And it should count per person (each row)
    I find the easiest way to sum your formula for each row in the column of age.
    =MIN(countif($B2:J2,$K$1),countif($B2:J2,$L$1))+MIN(countif($B3:J3,$K$1),countif($B3:J3,$L$1)) etc.

    What do you think?

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

    Re: Count if/Sum if/ or Sum product

    You just want to count the combination in $K$1 AND $L$1 per row?

    If so, I think the solution in #25 will do what you want.

    Otherwise show us a file what you try to do.

  28. #28
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    Look at the comment in the attachment.

    After you looked at it, the question arises:

    Is the easiest to count it for each column, to sum the outcome per row with your formula?
    Attached Files Attached Files

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

    Re: Count if/Sum if/ or Sum product

    If the condition is:

    You just want to count the combination in $K$1 AND $L$1 per row?

    Then the answer in P10 is the right answer and working with an helpcolumn would (to my opinion) be the easied way.

    If the conditions are differant you need another formula.

    The formula in B11 counts how many times in the whole range B2:J9 are values with the conditions in $K$1 en $L$1.

    In that case 9 is the right anwer.

  30. #30
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: Count if/Sum if/ or Sum product

    Thnx for your answer.

    Just one more question. What does the function Min( in this formula? Why do you use it?

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

    Re: Count if/Sum if/ or Sum product

    Please Login or Register  to view this content.
    it counts how many values are equal to K1
    it counts how many values are equal to L1

    MIN counts the minimum of the values

    e.g. that means if the answer of equal K1 = 10 and the answer of equal L1 = 4

    It means there are 4 combinations of K1 AND L1.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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