Skip to main content
Newcomer
Aug 16, 2024 2:25 PM UTC
Solved

Can MultiplyUnbalanced function take more than 2 components

Hello OneStream experts:

Thank you for the helps in the past. I found this forum is very helpful. 

I feel the MultiplyUnbalanced function is very nice and wonder if it can take more than 2 components to multiply. They give an  example:

If I want to do

A#UnbalancedMultiplication=A#60000 x A#41000:U2#Parts   I can use the following:

api.Data.Calculate("A#UnbalancedMultiplication = MultiplyUnbalanced(A#60000, A#41000:U2#Parts, U2#Parts)")

But, if I want to do multiply three components

A#UnbalancedMultiplication=A#60000 x A#41000:U2#Parts x A#51000:U2#Material

how to use the MultiplyUnbalanced function?

Thank you in advance for any answers.

Employee - Sage
Aug 19, 2024 9:15 AM UTC

All buffer functions, including the regular operators, only work with two buffer at a time. You can either nest the function , or use an intermediate buffer.

Nesting (a bit hard to read but simple enough to write):

api.data.calculate("A#Unbalanced = MultiplyUnbalanced(MultiplyUnbalanced(A#60000, A#410000:U2#Parts, U2#Parts), A#41000:U2#Materials, U2#Materials)")

Intermediate buffer (more code but the buffer could potentially be reused):

Dim intermediate as DataBuffer = api.Data.GetDataBufferUsingFormula("MultiplyUnbalanced(A#60000,A#41000:U2#Parts, U2#Parts)")
api.Data.FormulaVariables.SetDataBufferVariable("parts", intermediate, False)
api.Data.Calculate("A#Unbalanced = MultiplyUnbalanced($parts, A#41000:U2#Materials, U2#Materials)")

 

3 replies

Employee - Sage
Aug 19, 2024 9:15 AM UTC

All buffer functions, including the regular operators, only work with two buffer at a time. You can either nest the function , or use an intermediate buffer.

Nesting (a bit hard to read but simple enough to write):

api.data.calculate("A#Unbalanced = MultiplyUnbalanced(MultiplyUnbalanced(A#60000, A#410000:U2#Parts, U2#Parts), A#41000:U2#Materials, U2#Materials)")

Intermediate buffer (more code but the buffer could potentially be reused):

Dim intermediate as DataBuffer = api.Data.GetDataBufferUsingFormula("MultiplyUnbalanced(A#60000,A#41000:U2#Parts, U2#Parts)")
api.Data.FormulaVariables.SetDataBufferVariable("parts", intermediate, False)
api.Data.Calculate("A#Unbalanced = MultiplyUnbalanced($parts, A#41000:U2#Materials, U2#Materials)")

 

Newcomer
Aug 19, 2024 6:39 PM UTC

JackLacava: Both of your suggestions are very helpful. Thanks a million!

OneStream Employee
Dec 6, 2024 9:15 PM UTC

This worked for me. I used your "nesting" approach.

As you mentioned, it becomes more of a readability issue.