Unbalanced Math Functions
Unbalanced Math Functions
Unbalanced math functions are required when performing math with two Data Buffers, where the second Data Buffer needs to specify additional dimensionality. The term Unbalanced is used because the script for the second Data Buffer can represent a different set of Dimensions from the other Data Buffer in the api.Data.Calculate text. These functions prevent data explosion. The four Unbalanced Math functions are:
-
AddUnbalanced
-
Example: api.Data.Calculate("A#TargetAccount = AddUnbalanced(A#OperatingSales, A#DriverAccount:U2#Global, U2#Global)")
-
-
SubtractUnbalanced
-
Example: api.Data.Calculate("A#TargetAccount = SubtractUnbalanced(A#OperatingSales, A#DriverAccount:U2#Global, U2#Global)")
-
-
MultiplyUnbalanced
-
Example: api.Data.Calculate("A#TargetAccount =MultiplyUnbalanced (A#OperatingSales, A#DriverAccount:U2#Global, U2#Global)")
-
-
DivideUnbalanced
-
Example: api.Data.Calculate("A#TargetAccount =DivideUnbalanced (A#OperatingSales, A#DriverAccount:U2#Global, U2#Global)")
-
When using Unbalanced Math functions, the first two parameters represent the first and second Data Buffers on which to perform the function. The third parameter represents the Members to use from the second Data Buffer when performing math with every intersection in the first Data Buffer. The math favors the intersections in the first Data Buffer without creating additional intersections.
It is important that the dimensionality of the Target (left side of the equation) matches the dimensionality of the first data buffer on the right side of the equation (argument 1).
Often, these functions would be used when one source data buffer is doing math with a specific data cell intersection. This could be a rate, driver, or some data cell input.
Unbalanced Math Functions Usage
Example using MultiplyUnbalanced in a working formula:
'Calculate Salary (A#50200) times Bonus Percent to create Bonus number. Use MultiplyUnbalanced formula to calculate.
'Use a technique to Not Process NoData Cells and 0 Data Cells for Salary account
'1st property is the data buffer with the least dimensions and matches dimensionality of destination data buffer. Follow Data Explosion rules
'2nd Property is the data buffer with the most dimensions
'3rd Property is the list of account related dimensions that make it unbalanced
'Run for only Base Entities and Local Currency
If (Not api.Entity.HasChildren()) And (api.Cons.IsLocalCurrencyforEntity()) Then
api.Data.Calculate("A#BonusUnbalanced = MultiplyUnbalanced(RemoveZeros(A#50200), A#BonusPercent:F#None:O#Forms:I#None:U2#None:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None, F#None:O#Forms:I#None:U2#None:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None)")
End If


