Print Page | Close Window

Error in Formula while calculating Percentage ...

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=8706
Printed Date: 16 May 2024 at 9:41pm


Topic: Error in Formula while calculating Percentage ...
Posted By: yasinirshad
Subject: Error in Formula while calculating Percentage ...
Date Posted: 22 Dec 2009 at 12:07am
Hi,
Am usin below formula,
IIF ({A.A_I} =0,0,convert(decimal(6,2),abs((({A.A_I})-abs({B.A_I}))/abs({A.A_I})*100)))
And get error "A number,currency,amount,boolean,date-time,or string is expected here" while 'convert' is highlighted.
 
Alternatively, Using Case as below:
(case {A.A_I} when '0' then '0' else convert(decimal(6,2),abs((({A.A_I})-abs({B.A_I}))/abs({A.A_I})*100)) end))
I get Error "The ) is missing" while 'case' is highlighted.
 
Thanks to help with any one of above formula's..whereas i need to calculate percentage...


-------------
Thanks,
Yasin.



Replies:
Posted By: lockwelle
Date Posted: 24 Dec 2009 at 6:47am
(case {A.A_I} when '0' then '0' else convert(decimal(6,2),abs(({A.A_I}-abs({B.A_I}))/({A.A_I}*100)) end))
I think has the correct the number of parens, but it is the wrong syntax...CR doesn't use the SQL case statement.
 
 
IIF ({A.A_I} =0,0,abs(({A.A_I}-abs({B.A_I})/(({A.A_I}*100)) should work for you value...again, CR doesn't use the SQL Server convert statement.
 
CR XI uses a syntax that is closer to vb6.
 
HTH
 



Print Page | Close Window