+ Reply to Thread
Results 1 to 9 of 9

Two Dimensional Conditional Counting

  1. #1
    Registered User
    Join Date
    03-03-2016
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    14

    Two Dimensional Conditional Counting

    In range B17:I20 in the attached I'm using a SUMPRODUCT formula to count the instances of Yes & No in the table above where certain criteria (Office, Date and Question Number) are met.
    As you can see, the criteria are in a mix of rows and columns.
    This works fine in small scale but when I'm dealing with 100 offices, many many questions and several years worth of data SUMPRODUCT becomes a little clunky and really slows things down.

    I've done some digging around and found something that looks like an alternative using SUMIFS/INDEX/MATCH (it's on a different Excel forum so I won't post a link) but I cannot seem to translate that into my workbook as I'm not summing numeric values but counting text ones.

    Does anyone know of an alternative to using SUMPRODUCT for this?

    Many thanks.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,913

    Re: Two Dimensional Conditional Counting

    Try this in cell B17:
    =COUNTIFS($B$2:$B$9,$A$15,$A$2:$A$9,$A17,OFFSET($B$2:$B$9,,MATCH($B$15,$C$1:$E$1,0)),B$16)

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Two Dimensional Conditional Counting

    I moved your table to column J

    In K2

    =COUNTIFS($B:$B,$J$16,$A:$A,$J18,$C:$C,K$17)

    Copy across and down BUT need to change $C:$C to $D:$D to each new question

  4. #4
    Registered User
    Join Date
    03-03-2016
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    14

    Re: Two Dimensional Conditional Counting

    Thank you both. Both approaches work well.
    Having to change the ranges for each question will prove to be a pain in the posterior as there are many questions, but it'll be a one time thing (hopefully) so once done it's done.

    The first solution saves me that hassle but I'm a little worried about the volatile nature of OFFSET causing slowdown.

    I shall give them both a try in the real workbook and go from there.
    Many thanks again.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Two Dimensional Conditional Counting

    I didn't use OFFSET because of its volatility (and the volatility of the your data): however, like many solutions, it is trade off between your time doing manual setup (changing ranges) versus the ability to copy formulae and copy across/down a range.

    How often are you going to run the analysis? Once (or more) a day/week? If it is once a day, does it really matter if it takes Excel 5 or 15 minutes to calculate? Go get a cup of coffee while it's working!

  6. #6
    Registered User
    Join Date
    03-03-2016
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    14

    Re: Two Dimensional Conditional Counting

    I couldn't agree with you more. I shall put the time in and set it up as per your solution and keep my fingers crossed that the powers that be do not want to change it in any way.

    The analysis is run every morning. Sadly not a case of 5 or 15 minutes as the full workbook pulls data from one workbook per office and combines it into one master workbook.
    When each office's workbook opens a calculation is forced (this is something necessary for those files to work properly but I'm not entirely sure why). This of course forces the master workbook to calculate too, meaning all the SUMPRODUCTS churning away over and over. Each import takes between 90 mins and 2 hrs!

  7. #7
    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,910

    Re: Two Dimensional Conditional Counting

    Can't you make the master workbook manual calculation only? That way you could delay any calculation until all of the data is entered.
    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.

  8. #8
    Registered User
    Join Date
    03-03-2016
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    14

    Re: Two Dimensional Conditional Counting

    The master one is already set to manual calculation. Problem is each of the office workbooks forces a calculation automatically when they open. This in turn forces the master to calculate too.
    If I could have ONLY the office workbooks calculate and not every other open workbook too then my issue would be solved.

    I should really find out why they need to calculate when they open, but sadly the chap who put all this together has moved on.

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Two Dimensional Conditional Counting

    Pl clarify
    Does Months in B column will be in ascending order always.
    Will be Office entry will be only once for each Month, like in your example.
    In the second table count is for each quarter as shown.

+ 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 two variables in a two dimensional table
    By ugalskov in forum Excel General
    Replies: 3
    Last Post: 04-08-2016, 05:09 PM
  2. Parse Data from one dimensional array into a 2 dimensional array.
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-30-2016, 07:29 AM
  3. Replies: 2
    Last Post: 01-02-2015, 04:24 PM
  4. Replies: 6
    Last Post: 02-04-2012, 06:57 PM
  5. More than 3 conditional format using VBA & a 2 dimensional lookup
    By Astroboy142 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2009, 04:54 PM
  6. Creating a 2-dimensional array from a 1-dimensional list
    By guywithcamera in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-27-2008, 06:34 PM
  7. [SOLVED] Create One-Dimensional Array from Two-Dimensional Array
    By Stratuser in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2005, 05:06 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