cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar

Using columns from data table as combo box items?

Is it possible to use column names from the data table as items in a combobox in a JMP application?

if so, how do I reference it in the application.

I have sales and quantity sold as two columns. I also have a bar graph

What I want to do is create a combobox with sales and quantity sold as the items. when sales is selected the the bar graph shows the values from the sales and when quantity sold is selected it shows a bar graph with quantity sold?

thanks

9 REPLIES 9
ian_jmp
Level X

Re: Using columns from data table as combo box items?

It would be more conventional to use column list boxes, but if you do need a combo box then try:

NamesDefaultToHere(1);

// Make a table

dt =

New Table( "Data",

  Add Rows( 0 ),

  New Column( "sales",

  Numeric,

  "Continuous",

  Format( "Best", 12 ),

  Set Values( [] )

  ),

  New Column( "quantity sold",

  Numeric,

  "Continuous",

  Format( "Best", 12 ),

  Set Values( [] )

  )

  );

// Get the column names in dt into a list

cols = dt << getColumnNames("String");

// Make a UI

nw =

NewWindow("Select a column from "||(dt << getName),

  cb = comboBox(cols),

  ButtonBox("OK", OKscript)

);

nw << sizeWindow(300, 200);

// Recover the selection from the UI

OKscript =

Expr(

  nw << closeWindow;

  myCol = cols[cb << get];

  Print(myCol);

);

Re: Using columns from data table as combo box items?

I am very new to JMP so please excuse these questions.

My table has 10-15 columns of which sales and quantity sold are two.

How do I reference just these two columns in the combo box, rather than all of them?

also, how do I do it in the application builder? do I have to write the script or is there a way to do it by drag and dropping in the module and then changing the properties.

pmroz
Super User

Re: Using columns from data table as combo box items?

If the columns Sales and Quantity Sold are unchanging, then just hard-code them into a combobox.  In Application Builder, drag a combobox into the design area.  By default it uses items "Item1" and "Item2".  Double-click on Item1 and change it to Sales.  Double-click on Item2 and change it to Quantity Sold.

Re: Using columns from data table as combo box items?

got it,thanks. but if I link each item say to a graph, can I do that.

please refer to the original post above.

do I create two graphs and then link it some how to the respective item or is it possible to do just one graph where the y-axis changes according to the item picked in the drop down menu

thanks


pmroz
Super User

Re: Using columns from data table as combo box items?

This presentation on Application Builder should be helpful.

Re: Using columns from data table as combo box items?

thank you so much. the presentation helped.

I am using the sample big class for this exercise.

If i want only height and weight in the combo box, what do I do? right now it is showing all


pmroz
Super User

Re: Using columns from data table as combo box items?

The combo box in my example is dynamic; it depends on what table you select.  You need to remove the portion of code that populates the combo box and change it to be hard coded to just show Height and Weight, as mentioned in my first response.

Re: Using columns from data table as combo box items?

ok makes sense thanks.


Re: Using columns from data table as combo box items?

next question:

how to I link the selection made in combo box to graph.

---if height is selected the graph needs to show height in the Y-axis

---if weight is selected the graph needs to show weight.