cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
KyleGorsage
Level I

Need help with for loop and assigning journals via button boxes

Hello, 

 

I started working with Jump on 10/12/2020, so I am very new to all of this. I have solved most of the issues with this community board but I am completely stuck with this one. 

 

I am attempting to create a tracker for technician training, hour logs, etc. I am using a for loop to gather the information and turn it into data tables to be graphed. I then, in the same for loop, create a button and append it to the main window for each technician. When the button is pressed, the technician's window comes up as a journal with 2 outline boxes. 

 

Tecchtracker.PNGtracker main.PNG

 

Now, here's the issue:

 

When the button is pressed it opens a journal with the 2 outline boxes and the graph inside the correct outline box, however, the graph is only representative of the last name in the list. All of the graphs show the same data. I have tried countless things to try and fix this issue, but I am not experienced enough to see what I am missing. 

Here is my script: (Be advised, the first section of the script are SQL scripts that I use to pull live data from another database. You will not be able to run this script)

 

// New Technician Tracker Script

//=== CLEAN UP WORKSPACE ===

Names Default To Here( 1 );
Clear Log();
//Close All(Windows, No Save);
Close All( Data Tables, No Save );
Close All( Journals, No Save );
Clear Symbols();

Write( "Cleaning up workspace\!N\!N" );

//Generating Main Page to append to
New Window( "Team Tracker",
	Outline Box( "Team Tracker",
		H List Box(
			V List Box(
				sh1 = Border Box( Left( 100 ), Right( 100 ), Top( 75 ), Bottom( 75 ), sides( 15 ),
					V List Box(
						Button Box( "Shift 1",
							New Window( "Shift 1 Journal", <<journal, Button Box( "Close Journal", Close All( Journals, No Save ) ) )
						)
					)
				)
			)
		)
	)
);
 

//YTD OPS Hours

dtops = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('OPS')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtops << set name( "Year To Date OPS Hours" );

//YTD PM Hours

dtpm = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('PM')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtpm << set name( "Year To Date PM Hours" );

//YTD CM Hours

dtcm = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('CM')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtcm << set name( "Year To Date CM Hours" );

//YTD PR Hours

dtpr = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('PR')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtpr << set name( "Year To Date PR Hours" );

//YTD Trainee Hours

dttrainee = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and c.craft in ('TRAINEE')
--and a.worktype = ('OPS')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dttrainee << set name( "Year to Date Trainee Hours" );

//YTD Trainer Hours

dttrainer = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and a.reportdate >= '01-01-2020'
and a.istask = 0
and c.craft in ('TRAINER')
--and a.worktype = ('OPS')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dttrainer << set name( "Year to Date Trainer Hours" );

//Compiling all Hours into single table

dtcombined = Data Table( "Year to Date OPS Hours" ) << Concatenate(
	Data Table( "Year to Date CM Hours" ),
	Data Table( "Year to Date PM Hours" ),
	Data Table( "Year to Date PR Hours" ),
	Data Table( "Year to Date Trainer Hours" ),
	Data Table( "Year to Date Trainee Hours" )
);

dtcombined << set name( "Total Hours for all WO's" );
dtcombined << New Column( "Technician Full Name",
	Character,
	"Continuous",
	Format( "Best", 12 ),
	Formula(
		If(
			:IDSID == "AHUTCHEN", "Angela Hutchens",
			:IDSID == "CTSPEARM", "Colby Spearman",
			:IDSID == "EBROWN", "Eric Brown",
			:IDSID == "EGILLIS", "Eric Gillispie",
			:IDSID == "GJGOWENS", "Gary Gowens",
			:IDSID == "NFATHERE", "Andy Fatheree",
			:IDSID == "NMCENTE", "Nico Mcentee",
			:IDSID == "RJDELAH", "Ricardo De La Hoya",
			:IDSID == "SPHILLI1", "Steven Phillips",
			:IDSID == "SSKELDI", "Scott Skelding",
			:IDSID == "TBUCZKOW", "Tyler 'Buck' Buczkowski",
			:IDSID == "TRISTONE", "Triston Evans",
			:IDSID == "TYLERELL", "Tyler Ellis",
			:IDSID == "TSFRAKES", "Tyler Frakes "
		)
	),
	Set Display Width( 88 )
);

//Creating Tech list

tech_list = (dtcombined << Tabulate( Show Control Panel( 0 ), Add Table( Row Table( Grouping Columns( :Technician Full Name ) ) ) ));
list = tech_list << Make Into Data Table;
list << set name( "Technicians" );
list << delete column( :N );
ntechnicians = N Rows( list );
techlist = list:Technician Full Name << get values;

//Creating Data Tables for each technician individually

For( itechnician = 1, itechnician <= ntechnicians, itechnician += 1,
	technician_name = techlist[itechnician];
	dtcombined << Select Where( :Technician Full Name == technician_name );
	dtcombined << Subset( (Selected Rows( 1 )), selected columns( 0 ), output table name( technician_name || "_Full_Data" ) );
		
	//Extracting hour types by Work Type
	
	Data Table( technician_name || "_Full_Data" ) << New Column( "PM Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "PM", :Actual Labor Hours, 0 ) )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "Trainer Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Assignment Craft == "TRAINER", :Actual Labor Hours, 0 ) ),
		Set Display Width( 88 )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "Trainee Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Assignment Craft == "TRAINEE", :Actual Labor Hours, 0 ) )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "PR Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "PR", :Actual Labor Hours, 0 ) )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "CM Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "CM", :Actual Labor Hours, 0 ) ), 

	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "OPS Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "OPS", :Actual Labor Hours, 0 ) ),
		Set Selected
	);
	
//Tabulating to prepare data for graphing

	Tech_Tabulate_Temp = Data Table( technician_name || "_Full_Data" ) << Tabulate(
		Show Control Panel( 0 ),
		Add Table(
			Column Table( Analysis Columns( :Trainer Hours ) ),
			Column Table( Analysis Columns( :Trainee Hours ) ),
			Column Table( Analysis Columns( :PR Hours ) ),
			Column Table( Analysis Columns( :CM Hours ) ),
			Column Table( Analysis Columns( :PM Hours ) ),
			Column Table( Analysis Columns( :OPS Hours ) )
		)
	);
	
	Tech_Tabulate = Tech_Tabulate_Temp << Make Into Data Table;
	Tech_Tabulate << set name( technician_name || "Tabulated" );
	
	//Changing labels for the sake of clarity
		
	Column( Tech_Tabulate, 1 ) << Set Name( "Trainer Hours" );
	Column( Tech_Tabulate, 2 ) << Set Name( "Trainee Hours" );
	Column( Tech_Tabulate, 3 ) << Set Name( "PR Hours" );
	Column( Tech_Tabulate, 4 ) << Set Name( "CM Hours" );
	Column( Tech_Tabulate, 5 ) << Set Name( "PM Hours" );
	Column( Tech_Tabulate, 6 ) << Set Name( "OPS Hours" );
	
	//Transposing for optimal graphing
	
	Prepared_Tech_Data = Tech_Tabulate << Transpose(
		columns(
			:Name( "Trainer Hours" ),
			:Name( "Trainee Hours" ),
			:Name( "PR Hours" ),
			:Name( "CM Hours" ),
			:Name( "PM Hours" ),
			:Name( "OPS Hours" )
		)
			
	);
	ptd = Prepared_Tech_Data << set name( technician_name || "_Tabulated Transposed" );
	Column( 2 ) << Set Name( "Hours" );	
 
 //Creating a button for each technician for the main page
 
	tb = Button Box( technician_name,
		nw = New Window( "Technician Tracking",
			<<journal,
			Button Box( "Close Journal", Close All( Journals, No Save ) ),
			ob = Outline Box( "YTD Hours Breakdown", gbb = Graph Builder(
		Variables( X( :Hours ), Y( :Label ) ),
		show control panel( 0 ),
		show legend( 0 ),
		show title( 0 ),
		Elements( Bar( X, Y, Summary Statistic( "Sum" ), Label( "Label by Value" ) ) )
	); ),
			Outline Box( "Total Hours" )
		)
	);
	
	//Appending the created button to the main page, closing/ hiding tables
	
	sh1 << append( tb );
	Close( Data Table( technician_name || "_Full_Data" ), No save );
	Close( Data Table( technician_name || "Tabulated" ), No save );
	Data Table( technician_name || "_Tabulated Transposed" ) << show window( 0 );
	
	);
	

//Closing tables selectively

Close( Data Table( "Technicians" ), No save );
Close( Data Table( "Use for Graphs" ), No save );
Close( Data Table( "Use for Tech Tabulating" ), No save );
Close( Data Table( "Total Hours for all WO's" ), No save );
Close( Data Table( "Year to Date OPS Hours" ), nosave );
Close( Data Table( "Year to Date PM Hours" ), nosave );
Close( Data Table( "Year to Date CM Hours" ), nosave );
Close( Data Table( "Year to Date PR Hours" ), nosave );
Close( Data Table( "Year to Date Trainee Hours" ), nosave );
Close( Data Table( "Year to Date Trainer Hours" ), nosave );

Someone, please help me!

 

Thank you,

 

Kyle

8 REPLIES 8
Byron_JMP
Staff

Re: Need help with for loop and assigning journals via button boxes

would it work to make a graph with a local data filter?

that way you get all the dynamic linking between the graph and the data.

 

 

 

JMP Systems Engineer, Health and Life Sciences (Pharma)
KyleGorsage
Level I

Re: Need help with for loop and assigning journals via button boxes

I'm not sure what that would look like.

 

As I said, I started learning this last Monday, and am attempting to learn on the go here.

Byron_JMP
Staff

Re: Need help with for loop and assigning journals via button boxes

if all the data from all the techs were in one table, then you could make the graph builder figure you have and add a local data filter to change the graph contents for each level of tech.

 

Journals are kind of a pain to work with like this. Is there some specific reason you choose to this display method?

 

 

JMP Systems Engineer, Health and Life Sciences (Pharma)
KyleGorsage
Level I

Re: Need help with for loop and assigning journals via button boxes

The main reason I chose a journal was to display all of the graphs in one clean presentation. The goal with this project is to have multiple graphs of training progress, hours worked, certification progress, etc, and from what I was reading Journals seemed like the best choice. If there is an easier way to go, by all means, I'll do it another way! 

 

Can I add a filter function to the button box so that the graph is shown when you press the specific techs button? And I also changed the layout a little bit so they are now in tab boxes for easier sorting of information. My thought was that I could append each graph to the tab page box it belongs to

tabs.PNG

txnelson
Super User

Re: Need help with for loop and assigning journals via button boxes

I believe the issue is that your Graph Builder platform is always running against the last  table created for the last technician.

From what I can tell, there is a separate data table for each technician, and you need the Graph Builder to point to that specific data table.

If you change out with the following code, I believe you will get what you want.  As a note, I could not test this because no real data was posted

tb = Button Box( technician_name,
	nw = New Window( "Technician Tracking",
		<<journal,
		Button Box( "Close Journal", Close All( Journals, No Save ) ),
		ob = Outline Box( "YTD Hours Breakdown",
			Eval(
				Substitute(
						Expr(
							gbb = Data Table( __techName__ ) <<
							Graph Builder(
								Variables( X( :Hours ), Y( :Label ) ),
								show control panel( 0 ),
								show legend( 0 ),
								show title( 0 ),
								Elements(
									Bar(
										X,
										Y,
										Summary Statistic( "Sum" ),
										Label( "Label by Value" )
									)
								)
							)
						),
					Expr( __techName__ ), technician_name || "_Tabulated Transposed"
				)
			)
	
		),
		Outline Box( "Total Hours" )
	)
);
Jim
KyleGorsage
Level I

!Re: Need help with for loop and assigning journals via button boxes

Thank you for your reply!

 

The revision did not seem to fix the issue, it says the data table cannot be located in access or evaluation and that the argument for the graph is invalid. I'm not sure what data you need in order to help with this. I can copy all of the data tables and paste them here? Here are the tabulated transposed tables at least:

New Table( "Tyler Frakes_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Tyler FrakesTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Tyler FrakesTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[16.6666666666667, 67, 28.3666666666667, 277.383333333333,
			340.533333333333, 823.533333333333]
		)
	),
	Set Label Columns( :Label )
)
New Table( "Tyler Ellis_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Tyler EllisTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Tyler EllisTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [90, 82, 326.45, 419.966666666667, 315.65, 650.816666666667] )
	),
	Set Label Columns( :Label )
)
New Table( "Tyler 'Buck' Buczkowski_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Tyler 'Buck' BuczkowskiTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Tyler 'Buck' BuczkowskiTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [0, 67, 17.5, 233.05, 223.883333333333, 736.566666666667] )
	),
	Set Label Columns( :Label )
)
New Table( "Steven Phillips_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Steven PhillipsTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Steven PhillipsTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[27.5, 117, 93.9166666666667, 187.266666666667, 312.2, 632.333333333333]
		)
	),
	Set Label Columns( :Label )
)
New Table( "Triston Evans_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Triston EvansTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Triston EvansTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [6.5, 125, 658.533333333333, 259.233333333333, 281.7, 773.25] )
	),
	Set Label Columns( :Label )
)
New Table( "Scott Skelding_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Scott SkeldingTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Scott SkeldingTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[82.5, 21.2666666666667, 67.4166666666667, 185.4, 113.25,
			608.933333333333]
		)
	),
	Set Label Columns( :Label )
)
New Table( "Ricardo De La Hoya_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Ricardo De La HoyaTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Ricardo De La HoyaTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [25.5, 60.5, 7.25, 44.3333333333333, 96.5, 73] )
	),
	Set Label Columns( :Label )
)
New Table( "Nico Mcentee_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Nico McenteeTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Nico McenteeTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [17, 76, 86.9666666666667, 211.45, 210, 634.016666666667] )
	),
	Set Label Columns( :Label )
)
New Table( "Gary Gowens_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Gary GowensTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Gary GowensTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[16.5, 88.1666666666667, 58.5, 419.05, 236.083333333333,
			663.966666666667]
		)
	),
	Set Label Columns( :Label )
)
New Table( "Eric Gillispie_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Eric GillispieTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Eric GillispieTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [10, 76.2, 229.25, 180.866666666667, 316, 635.266666666667] )
	),
	Set Label Columns( :Label )
)
New Table( "Eric Brown_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Eric BrownTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Eric BrownTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[29.3333333333333, 57, 20.7166666666667, 88.8166666666667,
			148.966666666667, 723.516666666667]
		)
	),
	Set Label Columns( :Label )
)
New Table( "Colby Spearman_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Colby SpearmanTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Colby SpearmanTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [0, 24.3333333333333, 2.5, 54.5, 0, 116.8] )
	),
	Set Label Columns( :Label )
)
New Table( "Angela Hutchens_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Angela HutchensTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Angela HutchensTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [69.5, 0, 0, 3, 6, 11] )
	),
	Set Label Columns( :Label )
)
New Table( "Andy Fatheree_Tabulated Transposed",
	Add Rows( 6 ),
	New Script(
		"Source",
		Data Table( "Andy FathereeTabulated" ) <<
		Transpose(
			columns(
				:Trainer Hours,
				:Trainee Hours,
				:PR Hours,
				:CM Hours,
				:PM Hours,
				:OPS Hours
			),
			Output Table( "Transpose of Andy FathereeTabulated" )
		)
	),
	New Column( "Label",
		Character( 13 ),
		"Nominal",
		Set Values(
			{"Trainer Hours", "Trainee Hours", "PR Hours", "CM Hours", "PM Hours",
			"OPS Hours"}
		)
	),
	New Column( "Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [31.5, 23.9, 278.75, 109.2, 114.85, 793.516666666667] )
	),
	Set Label Columns( :Label )
)
KyleGorsage
Level I

Re: Need help with for loop and assigning journals via button boxes

Any other ideas on how I might solve this issue? You are correct about it only pulling from the last table. In your script, it calls upon the table of the last tech as well. Is there a way you can make it check the name of the button against the name of the table it is pulling up?

 

Thank you for your help

txnelson
Super User

Re: Need help with for loop and assigning journals via button boxes

I have reworked my code, and it appears to do the substitution correctly.  I am assuming that the Graph Builder should be running on data table Jim_Tabulated Transposed if the Jim button had been pressed, and if the Steve button had been pressed, it would run against Steve_Tabulated Transposed data table.

// New Technician Tracker Script

//=== CLEAN UP WORKSPACE ===

Names Default To Here( 1 );
Clear Log();
//Close All(Windows, No Save);
Close All( Data Tables, No Save );
Close All( Journals, No Save );
Clear Symbols();

Write( "Cleaning up workspace\!N\!N" );

//Generating Main Page to append to
New Window( "Team Tracker",
	Outline Box( "Team Tracker",
		H List Box(
			V List Box(
				sh1 = Border Box( Left( 100 ), Right( 100 ), Top( 75 ), Bottom( 75 ), sides( 15 ),
					V List Box(
						Button Box( "Shift 1",
							New Window( "Shift 1 Journal",
								<<journal,
								Button Box( "Close Journal", Close All( Journals, No Save ) )
							)
						)
					)
				)
			)
		)
	)
);
 

//YTD OPS Hours

dtops = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('OPS')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtops << set name( "Year To Date OPS Hours" );

//YTD PM Hours

dtpm = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('PM')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtpm << set name( "Year To Date PM Hours" );

//YTD CM Hours

dtcm = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('CM')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtcm << set name( "Year To Date CM Hours" );

//YTD PR Hours

dtpr = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and a.worktype = ('PR')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dtpr << set name( "Year To Date PR Hours" );

//YTD Trainee Hours

dttrainee = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and b.craft in ('Waste')
and a.reportdate >= '01-01-2020'
and a.istask = 0
and c.craft in ('TRAINEE')
--and a.worktype = ('OPS')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dttrainee << set name( "Year to Date Trainee Hours" );

//YTD Trainer Hours

dttrainer = Open Database(
	"DSN=SQL Database;Trusted_Connection=Yes;APP=JMP;WSID=KGORSAGE-MOBL1;",
	"select distinct a.siteid as 'Site ID', a.assetnum as 'Asset Number', a.wonum as 'Work Order Number', 
a.description as 'Work Order Description',  a.status as 'WO Status', 
a.worktype as 'Work Type', a.actfinish as 'Finish Date', a.actlabhrs as 'Actual Labor Hours', 
b.craft as 'Lead Craft', b.laborcode as 'IDSID', b.regularhrs as 'Assigned Hours', 
c.craft as 'Assignment Craft'

from MAXINTEL.hpm.hpm_workorder as a
left join (select refwo, siteid, laborcode, craft, regularhrs from MAXINTEL.hpm.hpm_labtrans) 
as b on a.wonum = b.refwo and a.siteid = b.siteid
left join MAXINTEL.hpm.hpm_assignment as c on a.wonum = c.wonum

where a.status in ('COMP', 'close') 
and a.reportdate >= '01-01-2020'
and a.istask = 0
and c.craft in ('TRAINER')
--and a.worktype = ('OPS')
and a.glaccount = ('54150')
and b.laborcode in ('AHUTCHEN','EBROWN','EGILLIS','CTSPEARM','GJGOWENS','NFATHERE', 'NMCENTE', 'RJDELAH','SPHILLI1','SSKELDI','TBUCZKOW', 'TRISTONE','TSFRAKES', 'TYLERELL')
Order by a.actfinish desc, b.laborcode"
);

dttrainer << set name( "Year to Date Trainer Hours" );

//Compiling all Hours into single table

dtcombined = Data Table( "Year to Date OPS Hours" ) << Concatenate(
	Data Table( "Year to Date CM Hours" ),
	Data Table( "Year to Date PM Hours" ),
	Data Table( "Year to Date PR Hours" ),
	Data Table( "Year to Date Trainer Hours" ),
	Data Table( "Year to Date Trainee Hours" )
);

dtcombined << set name( "Total Hours for all WO's" );
dtcombined << New Column( "Technician Full Name",
	Character,
	"Continuous",
	Format( "Best", 12 ),
	Formula(
		If(
			:IDSID == "AHUTCHEN", "Angela Hutchens",
			:IDSID == "CTSPEARM", "Colby Spearman",
			:IDSID == "EBROWN", "Eric Brown",
			:IDSID == "EGILLIS", "Eric Gillispie",
			:IDSID == "GJGOWENS", "Gary Gowens",
			:IDSID == "NFATHERE", "Andy Fatheree",
			:IDSID == "NMCENTE", "Nico Mcentee",
			:IDSID == "RJDELAH", "Ricardo De La Hoya",
			:IDSID == "SPHILLI1", "Steven Phillips",
			:IDSID == "SSKELDI", "Scott Skelding",
			:IDSID == "TBUCZKOW", "Tyler 'Buck' Buczkowski",
			:IDSID == "TRISTONE", "Triston Evans",
			:IDSID == "TYLERELL", "Tyler Ellis",
			:IDSID == "TSFRAKES", "Tyler Frakes "
		)
	),
	Set Display Width( 88 )
);

//Creating Tech list

tech_list = (dtcombined << Tabulate(
	Show Control Panel( 0 ),
	Add Table( Row Table( Grouping Columns( :Technician Full Name ) ) )
));
list = tech_list << Make Into Data Table;
list << set name( "Technicians" );
list << delete column( :N );
ntechnicians = N Rows( list );
techlist = list:Technician Full Name << get values;

//Creating Data Tables for each technician individually

For( itechnician = 1, itechnician <= ntechnicians, itechnician += 1,
	technician_name = techlist[itechnician];
	dtcombined << Select Where( :Technician Full Name == technician_name );
	dtcombined << Subset( (Selected Rows( 1 )), selected columns( 0 ), output table name( technician_name || "_Full_Data" ) );
		
	//Extracting hour types by Work Type
	
	Data Table( technician_name || "_Full_Data" ) << New Column( "PM Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "PM", :Actual Labor Hours, 0 ) )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "Trainer Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Assignment Craft == "TRAINER", :Actual Labor Hours, 0 ) ),
		Set Display Width( 88 )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "Trainee Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Assignment Craft == "TRAINEE", :Actual Labor Hours, 0 ) )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "PR Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "PR", :Actual Labor Hours, 0 ) )
	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "CM Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "CM", :Actual Labor Hours, 0 ) ), 

	);
	Data Table( technician_name || "_Full_Data" ) << New Column( "OPS Hours",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :Work Type == "OPS", :Actual Labor Hours, 0 ) ),
		Set Selected
	);
	
//Tabulating to prepare data for graphing

	Tech_Tabulate_Temp = Data Table( technician_name || "_Full_Data" ) << Tabulate(
		Show Control Panel( 0 ),
		Add Table(
			Column Table( Analysis Columns( :Trainer Hours ) ),
			Column Table( Analysis Columns( :Trainee Hours ) ),
			Column Table( Analysis Columns( :PR Hours ) ),
			Column Table( Analysis Columns( :CM Hours ) ),
			Column Table( Analysis Columns( :PM Hours ) ),
			Column Table( Analysis Columns( :OPS Hours ) )
		)
	);
	
	Tech_Tabulate = Tech_Tabulate_Temp << Make Into Data Table;
	Tech_Tabulate << set name( technician_name || "Tabulated" );
	
	//Changing labels for the sake of clarity
		
	Column( Tech_Tabulate, 1 ) << Set Name( "Trainer Hours" );
	Column( Tech_Tabulate, 2 ) << Set Name( "Trainee Hours" );
	Column( Tech_Tabulate, 3 ) << Set Name( "PR Hours" );
	Column( Tech_Tabulate, 4 ) << Set Name( "CM Hours" );
	Column( Tech_Tabulate, 5 ) << Set Name( "PM Hours" );
	Column( Tech_Tabulate, 6 ) << Set Name( "OPS Hours" );
	
	//Transposing for optimal graphing
	
	Prepared_Tech_Data = Tech_Tabulate << Transpose(
		columns(
			:Name( "Trainer Hours" ),
			:Name( "Trainee Hours" ),
			:Name( "PR Hours" ),
			:Name( "CM Hours" ),
			:Name( "PM Hours" ),
			:Name( "OPS Hours" )
		)
			
	);
	ptd = Prepared_Tech_Data << set name( technician_name || "_Tabulated Transposed" );
	Column( 2 ) << Set Name( "Hours" );	
 
 //Creating a button for each technician for the main page
	Eval(
		Substitute(
				Expr(
					tb = Button Box( technician_name,
						nw = New Window( "Technician Tracking",
							<<journal,
							Button Box( "Close Journal", Close All( Journals, No Save ) ),
							ob = Outline Box( "YTD Hours Breakdown", 
				
								gbb = Data Table( __techName__ ) << Graph Builder(
									Variables( X( :Hours ), Y( :Label ) ),
									show control panel( 0 ),
									show legend( 0 ),
									show title( 0 ),
									Elements( Bar( X, Y, Summary Statistic( "Sum" ), Label( "Label by Value" ) ) )
								)
							)
	
						,
							Outline Box( "Total Hours" )
						)
					)
				),
			Expr( __techName__ ), technician_name || "_Tabulated Transposed"
		)
	);
	
	//Appending the created button to the main page, closing/ hiding tables
	
	sh1 << append( tb );
	Close( Data Table( technician_name || "_Full_Data" ), No save );
	Close( Data Table( technician_name || "Tabulated" ), No save );
	Data Table( technician_name || "_Tabulated Transposed" ) << show window( 0 );
	
);
	

//Closing tables selectively

Close( Data Table( "Technicians" ), No save );
Close( Data Table( "Use for Graphs" ), No save );
Close( Data Table( "Use for Tech Tabulating" ), No save );
Close( Data Table( "Total Hours for all WO's" ), No save );
Close( Data Table( "Year to Date OPS Hours" ), nosave );
Close( Data Table( "Year to Date PM Hours" ), nosave );
Close( Data Table( "Year to Date CM Hours" ), nosave );
Close( Data Table( "Year to Date PR Hours" ), nosave );
Close( Data Table( "Year to Date Trainee Hours" ), nosave );
Close( Data Table( "Year to Date Trainer Hours" ), nosave );
Jim