Monday, March 19, 2012

Group expression that calculate percentages.

I have an expression in a group that calculates percent of sales:

=iif(Sum(Fields!BOOKD.Value)=0,0,IIF(Sum(Fields!NET.Value)=0,0,((Sum(Fields!BOOKD.Value)-Sum(Fields!NET.Value))/Sum(Fields!BOOKD.Value))))*100

The problem I'm having is that if both the

Sum(Fields!BOOKD.Value)=0 and

Sum(Fields!NET.Value)=0 ,

the expression returns the message #ERROR instead of a 0.

I have the initial query set to display 0 if the value is null.

,SUM(ISNULL(R.BOOKD,0))BOOKD
,SUM(ISNULL(R.NET,0))NET

I would greatly appreciate any help on how to solve this issue.

Thank Barb

IIF is a VB runtime function call which evaluates all arguments. Therefore, in the case of BOOKD being 0, you will get a division by zero.

Please read the following related thread on options to solve this: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=188577&SiteID=1

-- Robert

No comments:

Post a Comment