Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can any one tell me what the syntax error is in the code below 
here i am trying to find minimum of two values 

cpK.Expression = "IIF((Convert(point50,'System.Double') - Convert(LSL,'System.Double')) < ((Convert(USL,'System.Double') - Convert(point50,'System.Double')), Convert(point50,'System.Double') - Convert(LSL,'System.Double'), Convert(USL,'System.Double') - Convert(point50,'System.Double'))/3.0/Sigma"; 
Posted
Comments
Bernhard Hiller 17-Mar-14 11:12am    
What's the type of cpk?
Why don't you do those conversions before - that expression in unreadable!
FarhanShariff 17-Mar-14 11:29am    
Formula: Sigma = P90-P10/2.56 Cpk = Minimum|[ (P50 point - Lower) / 3 (sigma), (upper - P50 pint) / 3 (sigma)]|

DataColumn sigma = table1.Columns.Add("Sigma", typeof(double));
DataColumn cpK = table1.Columns.Add("CpK", typeof(double));

// set their expression properties
sigma.Expression = "Convert(point90,'System.Double') - Convert(point10,'System.Double')/2.56";

cpK.Expression = "IIF((Convert(point50,'System.Double') - Convert(LSL,'System.Double')) < ((Convert(USL,'System.Double') - Convert(point50,'System.Double')), Convert(point50,'System.Double') - Convert(LSL,'System.Double'), Convert(USL,'System.Double') - Convert(point50,'System.Double'))/3.0/Sigma";

1 solution

/3.0/Sigma
is at the wrong position. You must apply it to both possible choices:
cpK.Expression = "IIF((Convert(point50,'System.Double') - Convert(LSL,'System.Double')) < ((Convert(USL,'System.Double') - Convert(point50,'System.Double')), (Convert(point50,'System.Double') - Convert(LSL,'System.Double'))/3.0/Sigma, (Convert(USL,'System.Double') - Convert(point50,'System.Double'))/3.0/Sigma)";
 
Share this answer
 
Comments
FarhanShariff 18-Mar-14 9:55am    
still it says Syntax error in the expression

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900