Hi @jlrouquette and @Justin_Chilton,
I spent a little more time thinking about how to accomplish this join interactively in JMP, and I figured out a way to handle it through JMP Query Builder for Tables (Tables > Query Builder). This may or may not be faster than Justin's last solution, but it's worth a try. Below is a short video showing how I did it. General steps are as follows (easier than it sounds): 1) Sort lookup table ascending based on TVD, 2) Number the Formations 1..n, 3) Launch Tables > JMP Query Builder, 4) Setup Join to have WellName = WellReference, and BitDepth < TVD Reference, 5) Include only WellName, Bit Depth, and Formation Number as columns in new table, 6) Aggregate (min) on Formation Number; 7) Use Tables > Update to bring in Formation Reference based on Formation number.
I hope this might help!
@julian
edit: If you *do* want to go the scripting approach, I've attached an example script that uses the JMP Query Builder, and performs the update at the end to bring in the formation names. You will probably need to change based on what columns you want to end up with, but this should get you started. I think this might be much faster -- I was able to process a mock table of 250k rows in about 5 seconds.
edit 2: This definitely seems faster. 18 million rows processed in 7 minutes 56 seconds (MBP 2.7ghzi7, 16gb ram).
Names Default To Here(1);
//get handles for the tables
dt1 = Data Table( "MainTable" );
dt2 = Data Table( "LookupTable" );
//Sort Table
dt2 << Sort( By( :TVD Reference ), Order( Ascending ), Replace Table );
//Make formation number column
formNum = dt2 << New Column("Formation Num", Numeric);
formNum << Set Each Value(Row());
dt3 = qbTable = New SQL Query(
Version( 130 ),
Connection( "JMP" ),
JMP Tables(
//---------------------------
//Change table locations here if other names
//and change references in script
[
"LookupTable" => "_MEMORY_",
"MainTable" => "_MEMORY_"
]
//--------------------------
),
QueryName( "SQLQuery2" ),
Select(
Column( "WellName", "t1" ),
Column( "BitDepth", "t1" ),
Column(
"Formation Num",
"t2",
Alias( "Minimum-Formation Num" ),
SavedJMPName( "Formation Num" ),
Aggregation( "Minimum" )
)
),
From(
Table( "MainTable", Alias( "t1" ) ),
Table(
"LookupTable",
Alias( "t2" ),
Join(
Type( Left Outer ),
EQ( Column( "WellName", "t1" ), Column( "WellReference", "t2" ) ) &
LT( Column( "BitDepth", "t1" ), Column( "TVD Reference", "t2" ) )
)
)
),
Group By( Column( "WellName", "t1" ), Column( "BitDepth", "t1" ) )
) << Run;
//Update from Lookup table to get formation names
dt3 << Update(
With( dt2 ),
Match Columns( :Name( "Minimum-Formation Num" ) = :Formation Num ),
Add Columns from Update table( :FormationReference )
);