Forum Discussion

michaelkeung's avatar
michaelkeung
New Contributor III
2 years ago

multiply 2 cell value

Hi,

I need to create an account to calculate two values multiply together.

I had set formulapass2 and set the formula as below:

api.Data.ClearCalculatedData("A#COG762D:U1#None",True,True,True)
api.data.calculate("A#COG762D:U1#None = A#COG931:U1#ALLDEPT * A#KPI142:U1#1520")

It shows zeros while A#COG931:U1#ALLDEPT is 100 and A#KPI142:U1#1520 is 25.

May I know why?

 

Thank you.

  • michaelkeung's avatar
    michaelkeung
    New Contributor III

    I fixed it using below:

     

     

    Dim scnType As ScenarioType = api.Scenario.GetScenarioType()
    
    If (scnType = ScenarioType.Actual Or scnType = ScenarioType.budget) Then
    
    api.Data.ClearCalculatedData("A#COG762D:U1#None",True,True,True)	
    api.Data.Calculate("A#COG762D:U1#None:U2#None:U3#None:U4#None:U5#None:U6#None:U7#SysProLoad:U8#None:I#None:F#EndBalLoad:O#Import =  A#COG931:F#EndBal:U1#None:U2#None:U3#None:U4#None:U5#None:U6#None:U7#Actual:U8#None:I#None:F#EndBal:O#BeforeElim * A#KPI142:F#EndBal:U1#1520:U2#None:U3#None:U4#None:U5#None:U6#None:U7#Actual:U8#None:I#None:F#EndBal:O#BeforeElim / 100")
    
    End If

     

     

    • chul's avatar
      chul
      Contributor III

      Hi Michael,

      I have a couple of "best practices" tips for your member formula....

      1. Your Scenario Type condition isn't necessary when you write the member formula on the Scenario Types themselves.
      2. It would be good to add a condition to calculate on base entities in local currency only. Although this will run fast as written, customers may see a drastic performance improvement should there be high volumes of member formulas and business rules.
      3. This calc isn't durable data so the clear statement also isn't necessary IF the property Clear Calculated Data During Calc is set to True

      Obviously you can keep what you have since it's working but it's also important to know what I've mentioned above. Hope it helps!