bstori

Calculation Issue Workarond

Blog Post created by bstori Champion on Jun 4, 2016

@vadI was working on a site workflow that loops through a list to get all the payments towards an allocated amount. The person who gets a total allocation gets payments and my client needs to track these history payments towards an end goal of a zero balance. My workflow would query the list, get all the values, use a collection action to get out all the duplicates to then create another collection of all the titles (names). For each name, I would query the list to get all the values for that person and then for each value I would do a calculation action, if there is only one payment take the total allocated amount - approved payment = new balance, then update the master list with this new balance. If there is more then one payment within my loop I take the new balance - approved payment =  new balance.

 

The issue I was running into is when the balance would equal zero I would get a decimal number like this for example: 3.63797880709171E-12. I am not sure this is a known issue, but I wanted to post my workaround if others would run into the same thing.

 

For example: Total Allocation is $1,000.

Payment 1 = $500

Payment 2 = $500

Balance should now = 0 but would come out to be something like 3.63797880709171E-12 like I stated above.

 

So I created work a workaround that I wanted to share here today if others would run into this same issue. Because the number is such a small number I added an the following IF Statement

 

If the new balance is less then 0.009 and greater then -0.01 set variable of new balance = 0 and then update the list.

 

The workflow is basically a checks and balances type of workflow to make sure the main tracking list and the payment history list stay in sync to reduce errors.

Outcomes