Page 1 of 1

IF statements in Cognoscenti Insight

Posted: Wed Jan 29, 2014 1:25 pm
by Jwreford
Hi,

I have been trying to use an IF function in a calculation section but I keep getting a syntax error saying ; missing left parenthesis.

Can anybody help me solve this?
Thanks

Re: IF statements in Cognoscenti Insight

Posted: Wed Jan 29, 2014 1:40 pm
by declanr
If you post your code people will be able to tell you what is wrong with it.

Re: IF statements in Cognoscenti Insight

Posted: Wed Jan 29, 2014 1:42 pm
by kaazimraza
Jwreford wrote:Hi,

I have been trying to use an IF function in a calculation section but I keep getting a syntax error saying ; missing left parenthesis.

Can anybody help me solve this?
Thanks
Can you please post the code you're trying to get working?

Re: IF statements in Cognoscenti Insight

Posted: Wed Jan 29, 2014 6:17 pm
by Jwreford
Hi,

Sorry it would not let me post earlier, here is the code,
if(['ABS ERROR']=0,1,if(&(['ABS ERROR']>0,['FORECAST']=0,(1-['ABS ERROR']/['FORECAST']))

Thanks,

Joe

Re: IF statements in Cognoscenti Insight

Posted: Wed Jan 29, 2014 6:32 pm
by declanr
Jwreford wrote:Hi,

Sorry it would not let me post earlier, here is the code,
if(['ABS ERROR']=0,1,if(&(['ABS ERROR']>0,['FORECAST']=0,(1-['ABS ERROR']/['FORECAST']))

Thanks,

Joe
Try:

Code: Select all

['Destination']=N: If ( ['ABS ERROR'] =0, 1, If ( ( ['ABS ERROR'] > 0 ) & ( ['Forecast'] =0 ), 1- ( ['ABS ERROR'] \ ['FORECAST'] ), 0 ) );
You need to fill the 'Destination' part with whatever the destination measure is and the final 0 is just a guess on what you will want the result of the ELSE to be.

Re: IF statements in Cognoscenti Insight

Posted: Wed Jan 29, 2014 8:17 pm
by Jwreford
Hi Declan,

Thanks for the above to look like this
['IM ACC DATA Measures':'ACCURACY %']=N:If;(['ABS ERROR']=0,1,If((['ABS ERROR']>0)&(['Forecast']=0),0,1-(['ABS ERROR']\['FORECAST']));

But I get the message =N:if; missing semicolon

Thanks,

Joe

Re: IF statements in Cognoscenti Insight

Posted: Wed Jan 29, 2014 8:28 pm
by declanr
Jwreford wrote:Hi Declan,

Thanks for the above to look like this
['IM ACC DATA Measures':'ACCURACY %']=N:If;(['ABS ERROR']=0,1,If((['ABS ERROR']>0)&(['Forecast']=0),0,1-(['ABS ERROR']\['FORECAST']));

But I get the message =N:if; missing semicolon

Thanks,

Joe
Not sure where you gained the extra semicolon from but you need to take it out. I also missed a bracket from the end of the code i provided.

Code: Select all

['IM ACC DATA Measures':'ACCURACY %']=N:If(['ABS ERROR']=0,1,If((['ABS ERROR']>0)&(['Forecast']=0),0,1-(['ABS ERROR']\['FORECAST'])));