Skip to main content
August 16, 2024
Solved

Can MultiplyUnbalanced function take more than 2 components

  • August 16, 2024
  • 3 replies
  • 0 views

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.

Best answer by JackLacava

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

August 19, 2024

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)")

 

August 19, 2024

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

December 6, 2024

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

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