BookmarkSubscribeRSS Feed
ENTHU

Contributor

Joined:

May 13, 2018

Referencing to a specific data table

Hi,

 

I have a data table dtValues.I have sorted the data table as follows -

dtValues << Sort(
By( :test_end_date_1 ),
Order( Ascending ),
Output Table( "out_sorted" )
);

 

Now I want to get unique values from a column "weight" from the out_sorted table.

I tried the following code -

unique_wt = {};
unique_wt = Associative Array( dtValues:weight ) << Get Keys

But this code gives unique values from the table before sorting.I am looking for weight values from the sorted table.

How do I get around this?

 

 

4 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Re: Referencing to a specific data table

You need to set a pointer to the new data table that is being created.  The below code does that:

dtSorted = dtValues << Sort(
	By( :test_end_date_1 ),
	Order( Ascending ),
	Output Table( "out_sorted" )
);
 

unique_wt = {};
unique_wt = Associative Array( dtSorted:weight ) << Get Keys;
Jim
ENTHU

Contributor

Joined:

May 13, 2018

Re: Referencing to a specific data table

Thanks for the response.

But looks like 

unique_wt = Associative Array( dtSorted:weight ) << Get Keys;

outputs the key in ascending order by default.

I wanted to get the weight values in the order they appear in the column and not in ascending order.

Is there any other way to achieve this?

 

Thanks

txnelson

Super User

Joined:

Jun 22, 2012

Re: Referencing to a specific data table

The following quote is taken from the Scripting Guide, in reference to Associative Arrays

 

• Though associative arrays are not usually ordered, in JMP, keys are returned in
   alphanumeric order for the purpose of iteration and serialization.

Jim
ENTHU

Contributor

Joined:

May 13, 2018

Re: Referencing to a specific data table

Is there a work around for this? Like may be get all the values in the column and remove duplicates?

Without using associative arrays that is.