PDA

View Full Version : How to Merge two arrays with filter condition?



petevanderwa
10-16-2021, 09:41 AM
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

mana
10-16-2021, 05:33 PM
You can use Power Query

p45cal
10-17-2021, 04:41 AM
Best attach a workbook and a data file (or two).

snb
10-17-2021, 09:29 AM
Are you familiar with: https://www.clever-excel-forum.de/Forum-Excel

jolivanes
10-17-2021, 01:40 PM
Or with this?
http://www.vbaexpress.com/forum/forumdisplay.php?74-Non-English-Help