+ Reply to Thread
Results 1 to 10 of 10

Excel Functions needed for distinguishing records in a database

  1. #1
    Forum Contributor
    Join Date
    02-05-2013
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    Excel for Mac 2024
    Posts
    142

    Excel Functions needed for distinguishing records in a database

    I need help with the formula in column K in the attached workbook.

    It contains a database of companies that were included in an SEC filing submitted by an investment firm. The database contains 522 records in rows 6 – 528 and columns A thru K.

    The 522 records are comprised of 336 companies.

    Each company is listed either one, two, or three times – depending on whether the investment firm has invested in the Puts, the Calls, or the Stock.

    All combinations are included – Puts Only (1 record), Calls Only (1 record), Stock Only (1 record), Puts + Calls (2 records), Puts + Stock (2 records), Calls + Stock (2 records), Puts + Calls + Stock (3 records).

    Column G lists whether or not the investment was in the Stock Only (”O” for Only) or a combination (“C”) of the Stock plus either the Puts, Calls, or both. In other words, “C” includes Puts + Stock (2 records), Calls + Stock (2 records), and Puts + Calls + Stock (3 records).

    Column H denotes investments in Puts Only, and column I denotes investments in Calls Only.

    I need column K to denote (by a two letter symbol “PC”) investments made ONLY in the Puts and/or the Calls – i.e. including the Puts Only (1 record), Calls Only (1 record), or Puts + Calls (2 records).

    I tried a formula with AND, OR, and COUNTIF functions – to no avail. Please help!
    Attached Files Attached Files

  2. #2
    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,929

    Re: Excel Functions needed for distinguishing records in a database

    Could you provide some sample answers?
    You say your formula doesnt work, where and why is it not working - and what should it have returned?
    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

  3. #3
    Forum Contributor
    Join Date
    02-05-2013
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    Excel for Mac 2024
    Posts
    142

    Re: Excel Functions needed for distinguishing records in a database

    Yes. The values in red in column K denote where my formula is in error. It wrongly marks “PC” when there has been an investment in the Stock plus either a Put or a Call (2 records).

    The other values are correct.

  4. #4
    Forum Contributor
    Join Date
    02-05-2013
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    Excel for Mac 2024
    Posts
    142

    Re: Excel Functions needed for distinguishing records in a database

    Also, you also asked why my formula is in error. It is in error because it produces a “PC” when the ticker count is < 3. Well, that test is correctly satisfied when there is an investment in the Stock and only a Put or a Call, but that does not answer what I am going for. So, I know why it is wrong, but I have not been able to work out how to fix it.

  5. #5
    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,929

    Re: Excel Functions needed for distinguishing records in a database

    Quote Originally Posted by okcsteve View Post
    Yes. The values in red in column K denote where my formula is in error
    There are no entries in col K, I think you mean col J?

    If so, and using J31 as the 1st example...
    =IF(AND(OR(D31="Call",D31="Put"),COUNTIF(A$6:A$528,A31)<3),"PC","")

    Breaking that down
    =OR(D31="Call",D31="Put") = TRUE
    COUNTIF(A$6:A$528,A31)<3) = TRUE (count = 2)
    =IF(AND(TRUE,TRUE),"PC","")

    Can you explain why you think this is wrong?

  6. #6
    Forum Contributor
    Join Date
    02-05-2013
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    Excel for Mac 2024
    Posts
    142

    Re: Excel Functions needed for distinguishing records in a database

    It is wrong because it denotes a "PC" for an investment in ticker AWI that includes an investment in Stock. I need the formula to denote "PC" in situations where there is an investment only in Puts and/or Calls. So that includes Puts only, Calls only, and both Puts and Calls. If there is an investment in Stock in any combination, the formula should denote an empty "" value.

    So, specifically, the "<3" argument is wrong. I just don't know what to replace it with.
    Last edited by okcsteve; 05-20-2019 at 11:33 PM.

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

    Re: Excel Functions needed for distinguishing records in a database

    Still not sure I understand the full logic here, but consider changing the countif to countifS() which takes more criteria - so you can also test for STOCK?

  8. #8
    Forum Contributor
    Join Date
    02-05-2013
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    Excel for Mac 2024
    Posts
    142

    Re: Excel Functions needed for distinguishing records in a database

    The logic is that I want column J to tell me when the investment is ONLY in the Options (i.e. Put or Call, or Put and Call) and NOT in the Stock.

    I will work on COUNTIFS. Thanks for the suggestion.
    Last edited by okcsteve; 05-21-2019 at 12:15 AM.

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,548

    Re: Excel Functions needed for distinguishing records in a database

    Try pasting the following into cell J5 and copying down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  10. #10
    Forum Contributor
    Join Date
    02-05-2013
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    Excel for Mac 2024
    Posts
    142

    Re: Excel Functions needed for distinguishing records in a database

    JeteMc - Thank you for the response and so sorry for my delayed response. I am out of the country and without access to my computer. I am responding on my phone. I will look at your suggestion upon my return on Thursday when I can get to Excel and then respond back. Thanks again.
    Last edited by okcsteve; 05-28-2019 at 09:52 PM.

+ 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. Query Access database and return all records to Excel
    By bfs3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2014, 11:01 PM
  2. Need Excel Macro to get selective records, from Excel Based Database.
    By KetanVispute in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2013, 11:11 AM
  3. Database Functions: Randomization & Calling Records
    By biddum in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-02-2012, 10:06 AM
  4. Deleting all records in a access database table from Excel
    By Dave31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2008, 02:18 PM
  5. Issue trying to retrieve records from excel database
    By marktheman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2007, 04:24 PM
  6. Excel Functions for Records
    By marthasanchez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2006, 01:20 PM
  7. Extracting Records From Excel Database
    By thorvision in forum Excel General
    Replies: 5
    Last Post: 12-01-2005, 02:15 AM
  8. Database records from excel templates
    By BeeJay in forum Excel General
    Replies: 4
    Last Post: 06-22-2005, 10:05 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