Forum Discussion

SimpleLove's avatar
SimpleLove
New Contributor III
5 months ago

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 compon...
  • JackLacava's avatar
    5 months ago

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