Subscribe Bookmark RSS Feed

Set Chart Type using an If-statement

tarrild

Community Trekker

Joined:

Oct 11, 2011

Hi

I want to control the Chart Type of a Control Chart using an if-statement. I have tried the code beneath (with Eval, quotes ("), and just P, but get "Error for Control Chart on data table Emodulus: unknown chart type" ever time. How is this done?

Control Chart(

          Sample Size(

       If( Length( lstStatColumnCount[1] ) > 1,

                                        Column( lstStatColumnCount[1] ),

                                        :Batchno

                         )

          ),

          KSigma( 3 ),

          Chart Col( Column( lstStatColumn[1] ) ),

          Chart Type(

                         If( Length( lstStatColumnCount[1] ) > 1,

           Eval( P ),

                                        Eval( Individual on Group Means )

                         )

          ),

          SendToReport(

                         Dispatch(

                                        {},

                                        "Presummarize Control Chart",

                                        OutlineBox,

                                        Set Title( lstAxisLabel[1] )

                         ),

                         Dispatch(

                                        {},

                                        "2",

                                        ScaleBox,

                                        {Format( "Best", 10 ), Min( lstLegendMin[1] ), Max( lstLegendMax[1] ),

                                        Inc( lstLegendInc[1] ), Minor Ticks( 1 )}

                         )

          )

);

Best Regards

Tarrild

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

tarrild wrote:

OK, but I would really like not to write the Control Chart functions twice, since more options might be needed. Is there no way the set Control Chart options using a if-statement?

To be honest I dont know, I've never tried, and I wouldn't try because it is a very ugly style of programming.  Some people measure efficiency of code by how few lines have to be written, but this metric is not used by professional programmers unless they face severe memory constraints.  "Clever" code tends to be code that is difficult to understand when you look back on it and therefore costly to maintain.  The best method in my opinion would be to define your own user-defined function for producing a control chart to which you parse the parameters that you wish to control;  this will avoid having to write duplicate code (although you will of course have to write some code for the control chart)

-Dave
3 REPLIES
David_Burnham

Super User

Joined:

Jul 13, 2011

It would be much better to put the If statement outside of the Control Chart function:

If (condition,

     Control Chart( parameters-1 ... )

,

     Contol Chart( parameters-2

)

-Dave
tarrild

Community Trekker

Joined:

Oct 11, 2011

OK, but I would really like not to write the Control Chart functions twice, since more options might be needed. Is there no way the set Control Chart options using a if-statement?

Solution

tarrild wrote:

OK, but I would really like not to write the Control Chart functions twice, since more options might be needed. Is there no way the set Control Chart options using a if-statement?

To be honest I dont know, I've never tried, and I wouldn't try because it is a very ugly style of programming.  Some people measure efficiency of code by how few lines have to be written, but this metric is not used by professional programmers unless they face severe memory constraints.  "Clever" code tends to be code that is difficult to understand when you look back on it and therefore costly to maintain.  The best method in my opinion would be to define your own user-defined function for producing a control chart to which you parse the parameters that you wish to control;  this will avoid having to write duplicate code (although you will of course have to write some code for the control chart)

-Dave