Solved

# Project Summary - Cost/Rev Budgets

• 5 replies
• 75 views

Userlevel 4
• Jr Varsity III
• 35 replies

Hello,

Working on a GI to replicate some Excel reporting we are doing outside the system.

I am receiving an error on the Formula for “Margin in Backlog (%)” , the error is Divide by zero error encountered. Can anyone notice anything wrong with the below formula or another way to avoid the divide by zero error?

Thanks,

KT

Margin in Backlog (%) Formula

=100*((sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryRevisedAmount] <> 0, [PMBudget.CuryRevisedAmount], Null))-sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryActualAmount] <> 0, [PMBudget.CuryActualAmount], Null))-(sum(IIf( [PMBudget.Type]=[Cost] And [PMBudget.CuryRevisedAmount] <> 0, [PMBudget.CuryRevisedAmount], Null))-sum(IIf( [PMBudget.Type]=[Cost] And [PMBudget.CuryActualAmount] <> 0, [PMBudget.CuryActualAmount], Null))))/(sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryRevisedAmount] <> 0, [PMBudget.CuryRevisedAmount], Null))-sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryActualAmount] <> 0, [PMBudget.CuryActualAmount], Null))))

icon

Best answer by michellehesketh58 31 July 2023, 23:27

View original

### 5 replies

Userlevel 2

@ketiller,

I think the issue is when the result of functions following the “/” will result in 0 if the Actual and Budget amounts are both the same therefore resulting in the divide by zero error.  An option would be to add an initial comparison to see if the values are the same:

Consider:

IIf ([PMBudget.CuryRevisedAmount] = [PMBudget.CuryActualAmount] , 0,

100*(

(sum(IIf( [PMBudget.Type]=[Rev], [PMBudget.CuryRevisedAmount], Null))

-sum(IIf([PMBudget.Type]=[Rev] , [PMBudget.CuryActualAmount], Null))

-(sum(IIf( [PMBudget.Type]=[Cost], [PMBudget.CuryRevisedAmount], Null))

-sum(IIf( [PMBudget.Type]=[Cost], [PMBudget.CuryActualAmount], Null))

))

/(sum(IIf( [PMBudget.Type]=[Rev], [PMBudget.CuryRevisedAmount], Null))

-sum(IIf( [PMBudget.Type]=[Rev], [PMBudget.CuryActualAmount], Null))

)))

Just a quick thought on looking through your formula - would need to be tested in the GI.

I hope this helps!! Michelle

Userlevel 4

Hi @michellehesketh58

Thanks for the idea, I tried out the formula and got this error:

Thank you,

KT

Userlevel 2

@ketiller

Sorry - the grouping requires the sum for values on the first line:

Consider:

IIf (sum([PMBudget.CuryRevisedAmount]) = sum([PMBudget.CuryActualAmount]) , 0,

100*(

(sum(IIf( [PMBudget.Type]=[Rev], [PMBudget.CuryRevisedAmount], Null))

-sum(IIf([PMBudget.Type]=[Rev] , [PMBudget.CuryActualAmount], Null))

-(sum(IIf( [PMBudget.Type]=[Cost], [PMBudget.CuryRevisedAmount], Null))

-sum(IIf( [PMBudget.Type]=[Cost], [PMBudget.CuryActualAmount], Null))

))

/(sum(IIf( [PMBudget.Type]=[Rev], [PMBudget.CuryRevisedAmount], Null))

-sum(IIf( [PMBudget.Type]=[Rev], [PMBudget.CuryActualAmount], Null))

)))

Let me know if you have any other issues.

Thanks,

Michelle

Userlevel 4

Hi @michellehesketh58

Thanks for the feedback, we updated the formulas and had to add in the type since we are looking at revenue and cost.

=IIf (sum([PMBudget.Type]=[Rev] And [PMBudget.CuryRevisedAmount]) = sum([PMBudget.Type]=[Rev] And [PMBudget.CuryActualAmount]) , Null ,100*((sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryRevisedAmount] <> 0, [PMBudget.CuryRevisedAmount], Null))-sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryActualAmount] <> 0, [PMBudget.CuryActualAmount], Null))-(sum(IIf( [PMBudget.Type]=[Cost] And [PMBudget.CuryRevisedAmount] <> 0, [PMBudget.CuryRevisedAmount], Null))-sum(IIf( [PMBudget.Type]=[Cost] And [PMBudget.CuryActualAmount] <> 0, [PMBudget.CuryActualAmount], Null))))/(sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryRevisedAmount] <> 0, [PMBudget.CuryRevisedAmount], Null))-sum(IIf( [PMBudget.Type]=[Rev] And [PMBudget.CuryActualAmount] <> 0, [PMBudget.CuryActualAmount], Null)))))

From that, we received a new error message

Thank you,

KT

Userlevel 7

Hi @ketiller were you able to find a solution? Thank you!