I am writing a JSL code to import specification limits from a separate data table into the main data table.
// Open the Spec Limits table
specTable = Open("C:\Trending Tool Spec Limits.jmp");
// Open data table for analysis
dataTable = Data Table( "Trending data" );
// Extract Spec Limits and Show Limits from Spec Table
For Each Row(
specName = specTable:Variable[];
LSL = specTable:LSL[];
USL = specTable:USL[];
showLimits = specTable:Show Limits[]; // Assume Show Limits column has 1 for "show" and 0 for "hide"
// Get the corresponding column in the data table
col = Column( dataTable, specName );
// Set the Spec Limits property as an associative array
col << Set Property( "Spec Limits", {LSL( LSL ), USL( USL ), "Show Limits"( showLimits )}
);
);
// Close the Spec Limits table
Close( specTable, NoSave );The script is setting up the spec. limit property in all the correct places given by the spec. limit table, but it is not importing the actual spec limits. Any suggestions?
You can use Manage Limit platform for this if your data is in correct format
Names Default To Here(1);
dtLimits = New Table("Cities Limits",
Add Rows(4),
New Column("Process", Character, Set Values({"OZONE", "CO", "SO2", "NO"})),
New Column("LSL", Numeric, Set Values([0, 0, 0, 0])),
New Column("Target", Numeric, Set Values([0.2, 15, 0.05, 0.035])),
New Column("USL", Numeric, Set Values([0.4, 30, 0.1, 0.07])),
Set Label Columns(:Process)
);
dt = Open("$SAMPLE_DATA/Cities.jmp");
obj = dt << Manage Limits(
Process Variables(:OZONE, :CO, :SO2, :NO),
Load From Limits Table(dtLimits)
);
obj << Save to Column Properties;
If you wish to go your route, you need to evaluate the limits
Eval(EvalExpr(
col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), Show Limits(Expr(showLimits)}))
));
Thanks @jthi , works like a charm!
I updated my original script to evaluate the limits.
// Open the Spec Limits table
specTable = Open("C:\Trending Tool Spec Limits.jmp");
// Open data table for analysis
dataTable = Data Table( "Trending data" );
// Extract Spec Limits and Show Limits from Spec Table
For Each Row(
specName = specTable:Variable[];
LSL = specTable:LSL[];
USL = specTable:USL[];
showLimits = specTable:Show Limits[]; // Assume Show Limits column has 1 for "show" and 0 for "hide"
// Get the corresponding column in the data table
col = Column( dataTable, specName );
// Set the Spec Limits property as an associative array
Eval(EvalExpr(
col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), "Show Limits"n(Expr(showLimits)))})
);
);
// Close the Spec Limits table
Close( specTable, NoSave );
You can use Manage Limit platform for this if your data is in correct format
Names Default To Here(1);
dtLimits = New Table("Cities Limits",
Add Rows(4),
New Column("Process", Character, Set Values({"OZONE", "CO", "SO2", "NO"})),
New Column("LSL", Numeric, Set Values([0, 0, 0, 0])),
New Column("Target", Numeric, Set Values([0.2, 15, 0.05, 0.035])),
New Column("USL", Numeric, Set Values([0.4, 30, 0.1, 0.07])),
Set Label Columns(:Process)
);
dt = Open("$SAMPLE_DATA/Cities.jmp");
obj = dt << Manage Limits(
Process Variables(:OZONE, :CO, :SO2, :NO),
Load From Limits Table(dtLimits)
);
obj << Save to Column Properties;
If you wish to go your route, you need to evaluate the limits
Eval(EvalExpr(
col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), Show Limits(Expr(showLimits)}))
));
Thanks @jthi , works like a charm!
I updated my original script to evaluate the limits.
// Open the Spec Limits table
specTable = Open("C:\Trending Tool Spec Limits.jmp");
// Open data table for analysis
dataTable = Data Table( "Trending data" );
// Extract Spec Limits and Show Limits from Spec Table
For Each Row(
specName = specTable:Variable[];
LSL = specTable:LSL[];
USL = specTable:USL[];
showLimits = specTable:Show Limits[]; // Assume Show Limits column has 1 for "show" and 0 for "hide"
// Get the corresponding column in the data table
col = Column( dataTable, specName );
// Set the Spec Limits property as an associative array
Eval(EvalExpr(
col << Set Property("Spec Limits", {LSL(Expr(LSL)), USL(Expr(USL)), "Show Limits"n(Expr(showLimits)))})
);
);
// Close the Spec Limits table
Close( specTable, NoSave );
@jthi, when importing the spec limits with the EvalExpr function, the limits are imported but do not show up as limits before I open the spec. limit property window and press Apply. Do you know why, and what can be done to avoid this?
Are you sure your data in your spec limits table is numeric and not character?
Yes, it is numeric. It was saved from the Manage Limits platform.
Ah... now I did notice that you are using incorrect syntax for setting the limits, you are missing the list (squiggly brackets)
Names Default To Here(1);
dtLimits = New Table("Cities Limits",
Add Rows(4),
New Column("Variable", Character, Set Values({"OZONE", "CO", "SO2", "NO"})),
New Column("LSL", Numeric, Set Values([0, 0, 0, 0])),
New Column("USL", Numeric, Set Values([0.4, 30, 0.1, 0.07])),
New Column("Show Limits", Numeric, Set Values([1, 1, 1, 1]))
);
dt = Open("$SAMPLE_DATA/Cities.jmp");
For Each Row(dtLimits,
specName = dtLimits:Variable[];
low = dtLimits:LSL[];
high = dtLimits:USL[];
showLimits = dtLimits:Show Limits[];
Eval(Eval Expr(
Column(dt, specName) << Set Property("Spec Limits", {LSL(Expr(low)), USL(Expr(high)), Show Limits(Expr(showLimits))})
));
);
Close(dtLimits, NoSave);
Perfect, thanks! That did the trick!