+ Reply to Thread
Results 1 to 4 of 4

Countif function - horizontal and vertical textlookup

Hybrid View

  1. #1
    Registered User
    Join Date
    06-11-2014
    Posts
    4

    Countif function - horizontal and vertical textlookup

    I've seen similar threads out there for this topic, but I can't seem to find the answer to my problem.
    I have the following list of data on a worksheet that will be regularly added onto:

    Monthly Info
    A B C D
    1 Date Country CustomerName FlightType
    2 Jan-14 Spain JohnDoe Domestic
    3 Jan-14 France JohnDoe International
    4 Feb-14 Italy JohnDoe International
    5 Feb-14 Italy JohnDoe Domestic


    I have a second worksheet- Data Count- that I want to automatically count data from the above sheet as I enter it.

    Data Count
    A B C D E F G H I
    1 Blank Jan-14 Jan-14 Feb-14 Feb-14 Mar-14 Mar-14 Apr-14 Apr-14
    2 Blank Domestic International Domestic International Domestic International Domestic International
    3 France
    4 Italy
    5 Spain

    This second sheet needs to tally the flight by country, month, and flight type (domestic/international)- so there are 3 commands that need to be fulfilled.

    I'm able to count the number of flights by month and flight type by using a SUMIF array formula- here is what an example of the formula I've been using for Jan 2014 Domestic flights count:
    =SUM(IF('Monthly Info!A1:A5='Data Count'!B1,1,0),IF('Monthly Info'!A1:A5='Data count'!B2,1,0))

    However I can't seem to add to this function to include the country as I keep getting an error result. I think there might be an issue because this involves a horizontal lookup as opposed to vertical lookup?? Do I need to use a different type of function- SUMPRODUCT or something else??

    Thanks for any input! I've been researching for hours!!

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

    Re: Countif function - horizontal and vertical textlookup

    Your profile doesn't state which version of Excel you are using. If it is XL2007 or later then you can use COUNTIFS, like this in B3 of the Data Count sheet:

    =COUNTIFS('Monthly Info!$A$1:$A$5,B$1,'Monthly Info'!$D$1:$D$5,B$2,'Monthly Info'!$B$1:$B$5,$A3)

    Copy this down and across as required.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    06-11-2014
    Posts
    4

    Re: Countif function - horizontal and vertical textlookup

    Thanks so much! This works!

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

    Re: Countif function - horizontal and vertical textlookup

    On Data Count sheet,
    In A3
    =IFERROR(INDEX('Monthly Info'!$B$2:$B$5,MATCH(0,INDEX(COUNTIF(A$2:A2,'Monthly Info'!$B$2:$B$5),0,0),0)),"")
    and copy down.

    In B3
    =SUMPRODUCT(--('Monthly Info'!$B$2:$B$5=$A3),--('Monthly Info'!$A$2:$A$5=B$1),--('Monthly Info'!$D$2:$D$5=B$2))
    and then copy across and down.
    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.

+ 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] countif, fill horizontal, lookup vertical
    By tigaente in forum Excel General
    Replies: 4
    Last Post: 04-23-2012, 05:21 AM
  2. vertical to horizontal
    By giant in forum Excel General
    Replies: 4
    Last Post: 08-14-2010, 09:06 PM
  3. Horizontal To Vertical
    By khanjee in forum Excel General
    Replies: 3
    Last Post: 02-22-2008, 03:48 AM
  4. Vertical to Horizontal
    By billykiller05 in forum Excel General
    Replies: 3
    Last Post: 12-06-2007, 12:04 PM
  5. Horizontal to Vertical
    By Jett in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 10-04-2007, 03:37 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