how to script for finding maximum, minimum date value in a row for 100+ columnsi have a table with 500+ rows and 100+ columns. Populated with numeric values (dates). I need to find the maximum and minimum value along each row for earliest and latest date. i guess the script would be similar to 'Maximum (column1........column100)' for each row. But i am not sure how to script the column ranges along each row.
Advanced Statistical ModelingAutomation and ScriptingData Blending and CleanupMass CustomizationRe: how to script for finding maximum, minimum date value in a row for 100+ columnsMight this formula
If( Row() == 1,
nc = N Cols( Current Data Table() )
);
Mean( As Column( nc - 4 ), As Column( nc - 3 ),
As Column( nc - 2 ), As Column( nc - 1 ) );
be something in the direction you are looking for
Re: how to script for finding maximum, minimum date value in a row for 100+ columnsconsidering each column has values from each day; and i need to take the average of last 4 days data (average of 4 columns) and put this into a new column. how do i create a formula for this new column? where the references inside the formula will be changing every day?Re: how to script for finding maximum, minimum date value in a row for 100+ columnsIf you want to only use the 10th through the end of the data table, you can change the elements in the list used for the column specification. Here is a modification of the formula I previously submitted
If( Row() == 1,
theList = Current Data Table() << get column names( );
remove from( theList, 1, 9 );
);
Max( theLIst );
Documentation on List modification can be found in the Scripting Guide.
Re: how to script for finding maximum, minimum date value in a row for 100+ columnsHere's one way. Use 'Help > Scripting Index' and the 'JSL Scripting Guide' to understand whatever is unclear.
NamesDefaultToHere(1);
// Make some data
nr = 100;
nc = 50;
dt = AsTable(J(nr, nc, RandomNormal(0, 1)));
dt << setName("Some Random Continuous Columns");
// Define a contiguous range of columns to consider
startColNum = RandomInteger(1, Floor(nc/2));
endColNum = RandomInteger(Ceiling(nc/2), nc);
// Get the list of columns to include in the formulas
allCols = dt << getColumnNames;
myCols = allCols[startColNum::endColNum];
// Add the required formulas
CMD = Expr(dt << NewColumn("Row Maximum from Cols "||Char(startColNum)||" to "||Char(endColNum), Numeric, Continuous, Formula(Max(colsTBD))));
SubstituteInto(CMD, Expr(colsTBD), myCols);
CMD;
CMD = Expr(dt << NewColumn("Row Minimum from Cols "||Char(startColNum)||" to "||Char(endColNum), Numeric, Continuous, Formula(Min(colsTBD))));
SubstituteInto(CMD, Expr(colsTBD), myCols);
CMD;
Re: how to script for finding maximum, minimum date value in a row for 100+ columnshow to specify the range in the script, what exact symbols/characters to use in the script? that's what i am interested inRe: how to script for finding maximum, minimum date value in a row for 100+ columnsI think it'd be simple. Just create a new column with formula Min(:Col1, :Col2,....,:Coln)
You can drag and drop all columns into the formula editor.Re: how to script for finding maximum, minimum date value in a row for 100+ columnsif i want to use only a range of columns, NOT all columns, how do i script this? Lets say i want to use only 10th column to 100th column for all the rows; how do i script this?Re: how to script for finding maximum, minimum date value in a row for 100+ columnsHere is a simple formula that will find all of the continuous columns in your data table, and then calculate the maximum value for those columns. Just use it as the formula for a new column
If( Row() == 1,
theList = Current Data Table() << get column names( continuous )
);
Max( theLIst );
Re: how to script for finding maximum, minimum date value in a row for 100+ columnsHi @tonkatsu2020 ,
Something you might want to consider is whether or not your data table is "oriented" or arranged in the right way. Normally, you'd want to have a single column with data and then the rows would be each new instance of whatever it is you're looking at.
You might consider transposing your data. Then, it's just easy to find the Col Maximum() and Col Minimum(). However, this might not be what you're after. Can you share an anonymized version of your table? That might help in understanding how your data is structured and what you want to do with it.
DS
Re: how to script for finding maximum, minimum date value in a row for 100+ columnsHi,
Have you considered transposing your data (Rows become Column and reciprocaly)? You would then be able to use the Col Minimum and Col Maximum formulas.
Best,
TS