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
- :
- Re: weeks = 25; is from a dialog box. Please help with the column formula using ...

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

Highlighted

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

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

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

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

Created:
Aug 22, 2016 4:01 PM
| Last Modified: Oct 18, 2016 8:50 PM
(12976 views)
| Posted in reply to message from vinkane 08-22-2016

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 6

Highlighted
##

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

Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an input

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**)))**;

**)**;

Highlighted
##

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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an input

Highlighted
##

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

Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an input

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

Highlighted
##

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

Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an input

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"**)**

**)**

Highlighted

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

Created:
Aug 22, 2016 4:01 PM
| Last Modified: Oct 18, 2016 8:50 PM
(12977 views)
| Posted in reply to message from vinkane 08-22-2016

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", **)** **)**

**)**;

Highlighted
##

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

Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an input

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);

Article Labels

There are no labels assigned to this post.