+ Reply to Thread
Results 1 to 19 of 19

Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-month

  1. #1
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-month

    Hey guys,

    I'm stumped -- I'm trying to count survey responses (6 or 7 ONLY on a scale of 1-7) in August 2013 (but as a cell referenced month & year) but I need to add a month specific de-dupe to the formula. I need to do all this in one formula with no helper columns such that I can change the month to July 2013 and everything will just recalculate.

    I have the following data per column:
    Column C = Date
    Column J = How a customer rates shipping speed on a scale of 1-7
    Column AB = Customer ID

    Count Criteria:
    - If column J = either 6 or 7 (success)
    - If the date in column C is the same month as the date in C2 (success)
    - If the date in column C is the same year as the date in C2 (success)
    - If customer gives 2+ responses in August I want to count ONLY 6's & 7's, ONLY in August, and ONLY for the most recent August date in a descending list (FAIL)
    - Do not count N/A's (FAIL)
    - Do not count Blanks (success)

    Here is the formula I've been using:
    =SUMPRODUCT(--(MONTH(Sheet1!$C$2:$C$100)=MONTH($C$2)),--(YEAR(Sheet1!$C$2:$C$100)=YEAR($C$2)),--((Sheet1!$J$2:$J$100)>5))

    I've attached a XLSX file for reference and I highlighted duplicates Customer IDs in red and the rows actually I want to count in yellow.

    ExcelForum - jpeateDeDupe Formula.xlsx

    Thanks in advance for your help with this!!
    jpeate

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,258

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    The requirement that you ignore a specific month's previous value from a specific ID makes a single cell formula extremely complicated or even impossible, given the 'array of arrays of arrays' nature of the conditions. Helper column formulas can do it - and will 'just recalculate' as in the attached. This also addresses the problem (not shown in your example) of entirely duplicated data.

    ExcelForum - jpeate DeDupe Formula with helper columns.xlsx
    Last edited by Bernie Deitrick; 08-26-2014 at 02:55 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Quote Originally Posted by Bernie Deitrick View Post
    The requirement that you ignore a specific month's previous value from a specific ID makes a single cell formula extremely complicated or even impossible, given the 'array of arrays of arrays' nature of the conditions. Helper column formulas can do it - and will 'just recalculate' as in the attached. This also addresses the problem (not shown in your example) of entirely duplicated data.

    Attachment 341452
    Even though this was not the answer I was looking for:
    1) Wow, you are awesome and THANK YOU!!!
    2) You are correct -- My ultimate goal is incredibly difficult - the difficult part is trying to limit down the list (mid-formula) before I count 6's and 7's to only contain August records and to only contain the 6 or 7 related to the first time the customer_id shows up in August.
    3) If it helps, the dates will always be ordered from most recent date (at the top of the list) to the oldest date (at the bottom of the list) - so you can take the approach of A) taking the newest or two records, or B)the highest row value of two records ---- this is where I am stuck because I'm not seasoned enough to be able to do either of these. :/

    If we can get this into one cell, I can't even tell you how much this would change the game for me.

    Thanks,
    jpeate

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,258

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    There are a few people in the world who can figure out single-cell formulas like that - if they are possible at all - but I am not one of those select few. I'm of the opinion: whatever works .....

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Try this Array Formula. Since this is an array formula so you need to confirm it with Ctrl+Shift+Enter instead of just Enter.
    Please Login or Register  to view this content.
    Is this what you are trying to achieve?
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  6. #6
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Oh my god, you did it!!! I can't believe you actually pulled this off - same day no less. YES, this is exactly what I wanted!

    Did you invent excel? hahaha! I am super frickin' impressed! THANK YOU SKTNEER!

    Quick Follow-up question: If I simply replace "SUM" with "AVERAGE" will it basically average those same values using the same logic or does that change the nature of the calculation due to how the other functions combine with this first function?

    Awe-stickin,
    jpeate

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    You're welcome. Thanks for the feedback.
    The suggested formula was for counting the instances meeting the criteria. To get the average ( I assume you want the average of col. J values), try the following Array Formula which requires CSE (Ctrl+Shift+Enter).
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Sktneer, you rock man! This was exactly what I was looking for. All the calculations are coming through. I think their is some minimal rounding error occurring but thats the only downside.

    Thanks for all you help!
    jpeate

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    You're welcome.

    For that you can format the average cell with numbers with 2 decimal points.

    If that takes care your question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.
    Moreover you may also click on * (star) to Add Reputation if the solution provided helped you. This is another way to say thanks.

  10. #10
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Will definitely add reputation. If I have a follow-on questions to a posts that is solved, what is the best way to handle it? e.g. I wanted to ask about some iteration on this or another formula can I just do so in this thread?

    I'm slowly getting the logic behind this formula...

    I want to be respectful of the forum rules and I'm kinda struggling to iterate on this since match and frequency are still kind of new to me...

    Thank you!
    jpeate

  11. #11
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    So this formula is what I was looking for but I have one last tweak if you're willing to take a look. If I wanted to change the command

    FROM: "count 1 if J>5"

    TO: "count 1if J>5, K>5 and L>5" (i.e. all three must be true to count 1)

    ...how would I amend the above formula?

    Thanks,
    jpeate

  12. #12
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Big one ...
    But Great..
    sktneer..

    Vikas Gautam

  13. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Quote Originally Posted by jpeate View Post
    If I have a follow-on questions to a posts that is solved, what is the best way to handle it?
    jpeate
    In that case you will need to open a New Thread providing a link of solved thread which, you think, is related to your problem.

    Quote Originally Posted by jpeate View Post
    So this formula is what I was looking for but I have one last tweak if you're willing to take a look. If I wanted to change the command

    FROM: "count 1 if J>5"

    TO: "count 1if J>5, K>5 and L>5" (i.e. all three must be true to count 1)

    ...how would I amend the above formula?

    Thanks,
    jpeate
    Try this.....(Array Formula which requires CSE)
    Please Login or Register  to view this content.

  14. #14
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    @Vikas_Gautam

    Thanks.

  15. #15
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Wow. I've checked the numbers and its correct! This gave me exactly what I was looking for.

    There are not a lot of people who can wrap their head around problems like this one - this was truly incredible to witness.

    Thank you a thousand times!
    jpeate

  16. #16
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    You're welcome. Thanks for the feedback and compliment.
    Would you please mark your thread as Solved now.

  17. #17
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Hey Sktneer,

    This formula for averaging is very close but its off by a little bit. The numerator of the average formula is 727 but the formula calculates 720 for some reason (off by 7). Please see the attached spread sheet.

    I'm very new to arrays but excited to be learning. Can you help me get this formula over the finish line?

    Thanks in advance!
    John

    excel formula close but a little off - please help.xlsx


    Quote Originally Posted by sktneer View Post
    You're welcome. Thanks for the feedback.
    The suggested formula was for counting the instances meeting the criteria. To get the average ( I assume you want the average of col. J values), try the following Array Formula which requires CSE (Ctrl+Shift+Enter).
    Please Login or Register  to view this content.
    Attached Files Attached Files

  18. #18
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Yes you are correct. To get the correct sum, change the formula in C30 to this (remember this is an array formula).....

    In C30
    Please Login or Register  to view this content.
    Or simply to this.....
    Please Login or Register  to view this content.
    Last edited by sktneer; 09-03-2014 at 02:49 AM.

  19. #19
    Registered User
    Join Date
    08-25-2014
    Location
    USA
    MS-Off Ver
    MS Office 2011
    Posts
    11

    Re: Countif criteria for variable month/year but ONLY if 3rd value is latest, unique in-mo

    Hi Sktneer,

    It looks like the isn't taking the MONTH portion of the formula into account (see attached). Looks like a few values in September are being calculated. Am I looking at this correctly?

    array calculating wrong month values.xlsx

    Thanks,
    jpeate

+ 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. counting unique values across several criteria and date (month/year)
    By joannelittell in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-30-2013, 06:19 AM
  2. unique occurances per multiple criteria (including month/year)
    By joannelittell in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-09-2013, 04:54 PM
  3. [SOLVED] Pivot Table Not Grouping by Month for Latest Month (groups > 7/20/2013)
    By justforthis1 in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 09-04-2013, 12:28 PM
  4. If Column A Month and Year = ColumnB Todays Month and Year then send email
    By HACCStaff in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-15-2013, 12:47 AM
  5. countif by month and year
    By terryhong in forum Excel General
    Replies: 7
    Last Post: 05-15-2011, 05:01 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