turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- weeks = 25; is from a dialog box. Please help with the column formula using "wee...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 9:20 AM
(3900 views)

Having trouble using "weeks" in a column formula. weeks = 25; is from a dialog box. Help is appreciated

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 4:01 PM
(6900 views)

If you're familiar with Table Variables, no need to read further...

If your dialog box is part of a larger script, then MS' suggestion seems to be as streamlined as any. If collecting the value for "weeks" is all it is doing, you might consider ditching the script and creating a table variable called 'weeks'. Then use that in your formula:

To change the value for 'weeks', double click on the current value and type over it.

BTW - With proper scoping, changing the value for the table variable can be done by script, as well:

(Assuming dt = Data Table("Untitled 21") for the above example)

New Window**(** "Line Up Box",

<<**Modal**,

V List Box**(**

Lineup Box**(** N Col**(** **2** **)**, Text Box**(** "Set this value" **)**,

var = Number Edit Box**(** **45** **)**, **)**

**)**,

H List Box**(** Button Box**(** "OK", dt:weeks = var << **get** **)**,

Button Box**(** "Cancel", **)** **)**

**)**;

6 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 10:14 AM
(3789 views)

Not sure exactly what you have already, or where you need to end up. But maybe something like this?

dt = New Table**(** "Weeks",

Add Rows**(** **1000** **)**,

New Column**(** "Date",

Numeric,

"Continuous",

Format**(** "m/d/y", **10** **)**,

Input Format**(** "m/d/y" **)**,

Formula**(** Random Integer**(** Today**()** - In Years**(** **1** **)**, Today**()** **)** **)**

**)**

**)**;

wList = **{}**; For**(**w=**1**, w<=**52**, w++, InsertInto**(**wList, Char**(**w**)))**;

win = NewWindow**(**"Pick Week",

lb = ListBox**(**wList, maxSelected**(****1****))**,

ButtonBox**(**"OK", OKscript**)**

**)**;

OKscript =

Expr**(**

win << **closeWindow**;

w = **(**lb << **getSelected****)[****1****]**;

w = Num**(**w**)**;

form = Expr**(**If**(**Week Of Year**(**:Date**)** == wTBD, **1**, **0****))**;

SubstituteInto**(**form, Expr**(**wTBD**)**, w**)**;

dt << **NewColumn****(**"Match Selected Week", Numeric, Nominal, Formula**(**NameExpr**(**form**)))**;

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 10:48 AM
(3789 views)

Thanks for the try....the data table column( "Weeks to Roll" should = 25, a value needed by the user to evaluate a secondary operation.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 12:33 PM
(3789 views)

New Window("Line Up Box",

<<Modal,

V List Box(

Line Up Box(NCol(2),

Text Box("Set this value"), var = Number Edit Box(45),),),

H List Box(

Button Box("OK", ),

Button Box("Cancel" , )) );

weeks = var << get;

show (weeks);

Need to use the variable **"weeks"** in a numerical column formula. Previous post may have been confusing

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 2:25 PM
(3789 views)

One way is to update the formula through a button script (i.e. the "OK" button).

For example:

//Example table

dt = New Table**(**"weeks", Add Rows**(****10****)**, New Column**(**"Weeks to roll", Numeric**))**;

// User sets value and adds formula

New Window**(**"Line Up Box",

<<**Modal**,

V List Box**(**Lineup Box**(**N Col**(****2****)**, Text Box**(**"Set this value"**)**, var = Number Edit Box**(****45****)**, **)**, **)**,

H List Box**(**

Button Box**(**"OK",

Eval**(**Parse**(**"Column(\!"Weeks to roll\!")<<set formula(" || Char**(**var << **get****)** || ")"**))**

** )**,

Button Box**(**"Cancel"**)**

**)**

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 4:01 PM
(6901 views)

If you're familiar with Table Variables, no need to read further...

If your dialog box is part of a larger script, then MS' suggestion seems to be as streamlined as any. If collecting the value for "weeks" is all it is doing, you might consider ditching the script and creating a table variable called 'weeks'. Then use that in your formula:

To change the value for 'weeks', double click on the current value and type over it.

BTW - With proper scoping, changing the value for the table variable can be done by script, as well:

(Assuming dt = Data Table("Untitled 21") for the above example)

New Window**(** "Line Up Box",

<<**Modal**,

V List Box**(**

Lineup Box**(** N Col**(** **2** **)**, Text Box**(** "Set this value" **)**,

var = Number Edit Box**(** **45** **)**, **)**

**)**,

H List Box**(** Button Box**(** "OK", dt:weeks = var << **get** **)**,

Button Box**(** "Cancel", **)** **)**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 23, 2016 4:34 AM
(3789 views)

Just checked out the table variable solution and GREAT. Plus learned something new.

Using the script below....what would be the column formula using weeks ? Curious Thanks for the solution

New Window("Line Up Box",

<<Modal,

V List Box(

Line Up Box(NCol(2),

Text Box("Set this value"), var = Number Edit Box(45),),),

H List Box(

Button Box("OK", ),

Button Box("Cancel" , ))

weeks = var << get;

show (weeks);