//Code to Fit Line, based on status from 3rd column
dt=Current Data Table();
col_name_list = dt << get column names( string );
col= Column(dt,col_name_list[3]);
Bivariate(
Y( col_name_list[1] ),
X( col_name_list[2] ),
Fit Line( {Line Color( {213, 72, 87} )} ),
Where( col == "Zone1" )/*This is where I have an issue. If we give the actual column name as :Name("Zone") it works. I would like to use a variable to I can perform on new data sets*/
);
Bivariate(
Y( col_name_list[1] ),
X( col_name_list[2] ),
Fit Line( {Line Color( {213, 72, 87} )} ),
Where( col == "Zone2" )/*This is where I have an issue. If we give the actual column name as :Name("Zone") it works. I would like to use a variable to I can perform on new data sets*/
);
//Reference Data Below
/*
X Y Zone
0 18 Zone1
0.1 19 Zone1
0.2 20 Zone1
0.3 21 Zone1
0.4 22 Zone1
0.5 23 Zone1
0.6 24 Zone1
0.7 25 Zone1
0.8 26 Zone1
0.9 27 Zone1
1 28 Zone1
1.1 30 Zone2
1.2 29 Zone2
1.3 28 Zone2
1.4 27 Zone2
1.5 26 Zone2
1.6 25 Zone2
1.7 24 Zone2
1.8 23 Zone2
1.9 22 Zone2
2 21 Zone2
*/
Below is a script that runs using the structure of the code that you specified
Names Default To Here( 1 );
dt = Current Data Table();
col_name_list = dt << get column names( string );
Bivariate(
Y( col_name_list[1] ),
X( col_name_list[2] ),
Fit Line( {Line Color( {213, 72, 87} )} ),
Where( As Column( col_name_list[3] ) == "Zone1" )/*This is where I have an issue. If we give the actual column name as :Name("Zone") it works. I would like to use a variable to I can perform on new data sets*/
);
Bivariate(
Y( col_name_list[1] ),
X( col_name_list[2] ),
Fit Line( {Line Color( {213, 72, 87} )} ),
dt << select Where( As Column( col_name_list[3] ) == "Zone2" )/*This is where I have an issue. If we give the actual column name as :Name("Zone") it works. I would like to use a variable to I can perform on new data sets*/
);
I assume that you retrieved the code for the script by specifying the "Save Script: from the platform. Sometimes, when one uses a "By" in a platform, the script that is generated, creates all of the "Where Clause" code. When, what you really want to do, is to just specify the "By" as you did when you ran the platform interactively. Well, you can do that...below is the code with the "By" in it
Names Default To Here( 1 );
dt = Current Data Table();
col_name_list = dt << get column names( string );
Bivariate(
Y( col_name_list[1] ),
X( col_name_list[2] ),
Fit Line( {Line Color( {213, 72, 87} )} ),
By( col_name_list[3] )
);