Subscribe Bookmark RSS Feed

Corresponding Row for a Column Minimum

anandk

Occasional Contributor

Joined:

Mar 20, 2017

I am trying to find a corresponding row for a column Minimum "DEF" and trying to do that by column "GHI"?

I am able to find the Column Minimum for "DEF" but I am not getting the corresponding row value for column "ABC"?

 

I am using the following piece of code:

 

dt = current data table();
dt<<newColumn("BestB",numeric,continuous,Format("Best"),Formula(x = col minimum(:DEF,:GHI);));

dt<<newColumn("BestO",numeric,continuous,Format("Best"),Formula(rmat = dt << get rows where(:DEF == x);
r = rmat[1];
y = :ABC[r];));

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

See if this code provides you what you want

dt = Current Data Table();
dt << New Column( "BestB", numeric, continuous, Format( "Best" ), Formula( Col Minimum( :DEF, :GHI ) ) );
dt << New Column( "BestO",
	numeric,
	continuous,
	Format( "Best" ),
	Formula(
		dt=current data table();
		GHIValue = :GHI;
		:ABC[(dt<<get rows where( GHIValue == :GHI & :DEF == :BestB ))[1]];
	)
);
Jim
2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

See if this code provides you what you want

dt = Current Data Table();
dt << New Column( "BestB", numeric, continuous, Format( "Best" ), Formula( Col Minimum( :DEF, :GHI ) ) );
dt << New Column( "BestO",
	numeric,
	continuous,
	Format( "Best" ),
	Formula(
		dt=current data table();
		GHIValue = :GHI;
		:ABC[(dt<<get rows where( GHIValue == :GHI & :DEF == :BestB ))[1]];
	)
);
Jim
anandk

Occasional Contributor

Joined:

Mar 20, 2017

Thank you that worked for my script