Consulting

Results 1 to 5 of 5

Thread: How to Merge two arrays with filter condition?

  1. #1

    Question How to Merge two arrays with filter condition?

    Dear forum members,

    I have a problem, which I outlined in pseudo-code below.

    I need to merge two data sets with the criteria of a stock ticker (let's assume both data sets hold some information about stocks, uniquely identified by their ticker).

    Dataset 1 is already imported and will be stored in the array v1(). Data set 2 will be read and stored in the array v2(). I want to merge both arrays with the key variable "ticker" which is unique. Therefore, I need to add a merge condition I guess.

    That's what I do:

    [Import data to array v1]
    [Declare array v2]
    [Open data 2 file]

    [Open Do loop]
    Line = Split[Data row]
    d1 = Line(0)
    (1)
    [Convert d1 into date]
    (2)
    [For loop] with index k
    (3)
    Next
    (4)
    row = row + 1
    [Assign values to array v2]
    (5)
    [Close Do loop]
    (6)

    Now I am not sure where to add a filter condition in order to merge both data sets, and how this filter condition should look like. I guess it should be placed somewhere between (1) and (6).

    Also:
    - v1() contains the following variables in the order: date(1), ticker(2), bid(3), ask(4), price(5), returns(6)
    - dataset 2 contains the following variables in the order: date(1), ticker(2), bid(3), ask(4), price(5), returns(6)

    Thanks a lot! I am happy to be part of this community now and look forward to discuss with you!

    Best,
    Pete

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    785
    Location
    You can use Power Query

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,452
    Best attach a workbook and a data file (or two).
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,267

  5. #5

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •