Toggle button box or something similarHi JMP Community,
I'm trying to set up a window where users can select different months, or quarters, or the entire YTD, that also provides feedback of which button boxes have been selected (or even deselected). My intent is to ultimately use the month/quarter/YTD selection as a way to create a subset of a data table based on the month (year is always set to current year for now).
Here's a window of what I'm thinking about:

Whenever a month is selected, the code will define a variable as "01" for Jan, "05" for May, or "1" for Q1, etc. What I'd like is for the button to look like it's either "clicked" by appearing pressed, or better turn a highlighted color, like blue. Something similar to what happens in the Data Filter platform, like when using Big Class and adding a local Data Filter by :name, where the name is highlighted and more than one selection can be made at a time. Along with showing that the button has been selected, I would like it to show if the button has been deselected -- much like a check box showing it's marked or not -- but I don't want to use check boxes as it's less visually appealing.

The code for the window I created looks like (see below), and of course, when the user clicks on "OK", the code will then create the subset data table and then also close the selection window. In setting the variable for the month selected "mo#", is there a less cumbersome way to assign it the 01Jan2024 value than the code AsDate(Date DMY(dd,mm,yyyy))? it works just fine, it's just a bit cumbersome.
Names Default To Here( 1 );
yr = Year( Today() );
subwin = New Window( "Select Subset",
<<TYPE></TYPE>
Any help is much appreciated!
Thanks!,
DS
Automation and ScriptingData Blending and CleanupMass CustomizationWindowsRe: Toggle button box or something similarHi @jthi and @txnelson ,
Thank you both for the valuable feedback. All your suggestions gave me some ideas on what to work on and how to modify the existing code to get what I needed. I liked @txnelson 's idea of the start date and end date, but unfortunately, it doesn't allow non-continuous selection of months and or quarters. For example, a user might select Jan and Sep as months or Q1 and Q4 as quarters to then grab the subset from. So, I had to rewrite that to allow for non-continuous dates. I even threw in a check if the user was selecting months and quarters or YTD and any mix so they'd have to go back and select just one group or another.
My solution to this was actually to use Associative Arrays, and I was pleased with the outcome as well as utilizing AA's since I haven't really worked much with them. The code I came up with is below. I know it's not very elegant or compact, but it works and gets the job done, which is sometimes all that's needed, right?! 
Thanks for all the help and quick feedback. I love being able to pose a problem on this forum and then less than 24hrs later have a functioning script that solves all the concerns I needed. Below is the code I ended up writing:
Names Default To Here( 1 );
dt = Current Data Table();
yr = Year( Today() );
MonthAA = Associative Array( {"M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12"}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} );
QAA = Associative Array( {"Q1", "Q2", "Q3", "Q4"}, {1, 2, 3, 4} );
YTDAA = Associative Array( {"YTD"}, {12} );
MonthList = {};
QList = {};
QMonths = {};
YTDList = {};
ClearExpr = Expr(
dt << Clear Select;
MonthList = {};
QList = {};
QMonths = {};
YTDList = {};
BB1 << Set( 0 );
BB2 << Set( 0 );
BB3 << Set( 0 );
BB4 << Set( 0 );
BB5 << Set( 0 );
BB6 << Set( 0 );
BB7 << Set( 0 );
BB8 << Set( 0 );
BB9 << Set( 0 );
BB10 << Set( 0 );
BB11 << Set( 0 );
BB12 << Set( 0 );
BB13 << Set( 0 );
BB14 << Set( 0 );
BB15 << Set( 0 );
BB16 << Set( 0 );
BB17 << Set( 0 );
);
OKExpr = Expr(
dt << Clear Select;
MonthList = {};
QList = {};
QMonths = {};
YTDList = {};
For( i = 1, i <= 17, i++,
tempBB = Eval( Parse( "BB" || Char( i ) ) ) << Get;
If( tempBB == 1,
If(
Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "M", Insert Into( MonthList, Eval( Parse( "Sel" || Char( i ) ) ) ),
Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "Q", Insert Into( QList, Eval( Parse( "Sel" || Char( i ) ) ) ),
Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "Y", Insert Into( YTDList, Eval( Parse( "Sel" || Char( i ) ) ) )
)
);
);
If(
N Items( MonthList ) != 0 & N Items( QList ) != 0 | N Items( MonthList ) != 0 & N Items( YTDList ) != 0 | N Items( QList ) != 0 &
N Items( YTDList ) != 0,
ErrorWin = New Window( "Error Window",
<<TYPE></TYPE>
Thanks!,
DS
Re: Toggle button box or something similarI'm not sure how your data looks like or how you do wish to perform the selections but I would separate the UI and logic. I made modifications to your UI but it isn't necessary, this just makes it a bit easier to collect the buttons. This will just demonstrate how you can build the dates from months, it won't do it for YTD or Quarters as I'm not sure how you will be using those
Names Default To Here(1);
get_dates = Expr(
months = Loc(m_buttons << get, 1);
qs = Loc(q_buttons << get, 1);
ys = Loc(y_buttons << get, 1);
// loop over as necessary to create the combinations
dates_to_find = Transform Each({month}, months,
Date DMY(01, month, yr);
);
);
yr = Year(Today());
subwin = New Window("Select Subset",
<<TYPE></TYPE>Re: Toggle button box or something similarHere is a rework of your JSL.....it really isn't tested, however it should be close enough for you to use it to complete your request
Names Default To Here( 1 );
dt=current data table();
theYear = Year( Today() );
resetbb = Expr(
For( i = 1, i <= 17, i++,
Eval( Parse( "bb" || Char( i ) || "<< enable(1);" ) )
)
);
subwin = New Window( "Select Subset",
<<TYPE>= :Date < endDate );
dtSubset = dt << subset( selected columns( 0 ), selected rows( 1 ) );
subwin << Close Window;
),
Button Box( "Cancel/Exit", subwin << Close Window )
)
)
);
</TYPE>
Re: Toggle button box or something similarHi @jthi ,
This definitely solved the toggle problem I was after. Now, the only challenge is how to set up the logic structure when someone clicks "OK" so that it will select only those mm/yyyy rows in the data table for all possible combinations of months selected or quarters, etc. Trying to think of a way that this doesn't get really big really fast. Any ideas?
Thanks!,
DS
Re: Toggle button box or something similarYou can also group radio boxes so that only one will be active at any given time:
Names Default To Here( 1 );
r1 = Radio Box( {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} );
r2 = Radio Box( {"Q1", "Q2", "Q3", "Q4"} );
New Window( "Example", H List Box( r1, r2 ) );
r2 << Group( r1 );Re: Toggle button box or something similarButton Box supports Toggle style
Names Default To Here(1);
New Window("Toggle Button Example",
ex = Button Box("Start",
If(ex << Get,
ex << Set Button Name("Stop"),
ex << Set Button Name("Start")
)
)
);
ex << Style("Toggle");


Re: Toggle button box or something similarYou might use radio buttons for this purpose. You could use one set to define whether the period is months or quarters. You could have another dynamic set to offer either the twelve months or the four quarters. Both options could be created when the window is opened, but one set (not the default) could be invisible. The first set of radio buttons would manage the visibility of the second set as well as the logic.