Choose Language Hide Translation Bar
Highlighted
raeish
Level II

How to find weight measured nearest to specific dates?

Hi JMP Community :-)

 

Below is a table representing the data I'm looking at (in a lot smaller scale). I wish to create a list of the weights measured on the dates closest to "Arrival dates" for the specific IDs.

 

I used JMP to get my data in this order, and I tried combining Excels INDEX, MATCH and OFFSET functions to get my desired list, but can't seem to get the right result.

 

Hope someone out there can help :-)

 

Kind regards,

Rae

 

IDARRIVAL DATEDATE1WEIGHT1DATE2WEIGHT2DATE3WEIGHT3DATE4WEIGHT4 DATE NEAREST ARRIVALWEIGHT NEAREST ARRIVAL
1234567841109.5843108.556039681.386238227.885842507.2861   
2345678142634.7742509.910042634.7711141948.610540128.4112   
3456781238087.2842234.544541578.414638087.2845.541733.0347   
4567812341221.3340842.345842575.535741221.3358.542003.3558   
5678123442025.3742025.376539900.696640925.146541464.5467   
6781234538821.7439075.547043005.437141185.526938821.7470   
7812345639074.1140477.915039074.1115139310.4315341505.26150   
8123456742515.4937998.559241824.978942626.119341051.3492   
9 REPLIES 9
Highlighted
txnelson
Super User

Re: How to find weight measured nearest to specific dates?

If I am understanding exactly what you need, I think the attached data table has the formulas for the 2 new columns you want that will produce the below results:

nearest.PNG

Jim
Highlighted
raeish
Level II

Re: How to find weight measured nearest to specific dates?

Wow! You deserve a medal! AMAZING! Thank you SO much!

Highlighted
raeish
Level II

Re: How to find weight measured nearest to specific dates?

Wow! You deserve a medal! AMAZING! Thank you SO much txnelson!

Highlighted
kocemba
Level II

Re: How to find weight measured nearest to specific dates?

Hi txnelson,

 

First of all thanks for taking the time to answer.

 

I am working with Raeish on this.

Could the formula be tweaked for another variable to only find the date nearest (before) but not equal to arrival date and the corresponding value at that time?

Highlighted
txnelson
Super User

Re: How to find weight measured nearest to specific dates?

Attached is the same data table as I attached before, now with new formulas.

 

Please take the time to read the documentation on formula creation in

     Help==>Books==>Using JMP

and

     Help==>Books==>Scripting Guide

Jim
Highlighted
raeish
Level II

Re: How to find weight measured nearest to specific dates?

Hi Jim :-) Again, thank you so much for taking your time to reply :-)

We will definitely read about formula creation - Thank you for the tip!

 

As for the last file you sent, I've tried adding it to the previous formula - but it doesn't seem to change anything. You wrote that you sent the same data table as before(just with a new formula) but when I open it I only get this short formula, not the entire table. Is that right?

 

names default to here(1);

dt=current data table();

 

 

for each row(

dateMatrix = Matrix(:Date1,:Date2,:Date3,:Date4);

Show(dateMatrix);

 

)

 

 

Thank you again,

Kind regards

- Rae

Highlighted
txnelson
Super User

Re: How to find weight measured nearest to specific dates?

My error....I attached the wrong file....I think the new attachement will work better

Jim
Highlighted
raeish
Level II

Re: How to find weight measured nearest to specific dates?

Great! THANK YOU!

 

One more question: is there a way to add the criteria that the weight nearest arrival has to be within 2 days of arrival(and if no such date exist leave it blank)?

 

Kind regards,

Rae

Highlighted
txnelson
Super User

Re: How to find weight measured nearest to specific dates?

Attached is a new version of the formulas.  I am not sure if your date columns are JMP date/time columns.  I made the assumption they are, and therefore, I use the In Datys() function to calculate the number of days to subtract for the comparison.  If your column is not a JMP date/time value, you need to change the subtraction to the value for a day.

Jim
Article Labels

    There are no labels assigned to this post.