Forum Discussion

RandyThompson's avatar
RandyThompson
New Contributor III
6 days ago

Use api.Data.Calculate to move data between 2 cubes

Is it possible to copy a value from one cube to another mutually exclusive cube with a Custom Calculate business rule? I am trying to copy a value from the Cb#Financial cube to the Cb#CASH cube.  However, using the “api.Data.Calculate” code below I get the error “Invalid destination data unit in script” even though the Data Unit defined in my Data Management step matches the target cube Data Unit.

Dim sTops As String     = ":C#Local:S#AOP_Final:V#Periodic:A#BGMOPEX:F#EndBal_Input:O#BeforeAdj:I#None:U1#TopUD1:U2#TopUD2:U3#SALARY:U4#TopUD4:U5#TopUD5:U6#TopUD6:U7#None:U8#GC_USD"     

Dim sNones As String = ":Cb#CASH:E#US01:S#CashForecast_Forecast:T#2024M10:C#Local:V#Periodic:F#EndBal_Input:O#Forms:I#None:U1#None:U2#None:U3#NoVendor:U4#None:U5#None:U6#CashForecast_Plan:U7#None:U8#GC_USD"                                                                                                                                                             

Dim dPayroll As Decimal = api.Data.GetDataCell("Cb#Financial:E#US01" & sTops & ")").CellAmount    api.Data.Calculate("A#PAYUSA" & sNones & " = RemoveZeros(" & dPayroll & ")",True) 

In the past I have used the “BRApi.Finance.Data.SetDataCellsUsingMemberScript(si, objMemberScriptValues)” method and the “DM Data Export / Import” method to move data between cubes, but I was hoping that I could use a simple api.Data.Calculate utilizing the “Cb#” filter. Is this possible? Thanks.

  • 		#region Pull Cashflow from Financial
    		private void Cash_Pull_from_Financial(SessionInfo si, FinanceRulesApi api)
    		{
    			//Simple Data Pull
    			DataBuffer sourceDB = new DataBuffer();
    			sourceDB = api.Data.GetDataBufferUsingFormula("cb#Financial:S#ACTUAL:C#Local:F#None:O#Forms:A#SourceAccount:UD2#None:U4#None:UD5#None:U6#None:UD7#None:U8#None");
    			api.Data.FormulaVariables.SetDataBufferVariable("srcFinancial", sourceDB, true);
    				
    			api.Data.ClearCalculatedData("F#None:O#Forms:A#RateAccount:UD2#None:U4#None:UD5#None:U6#None:UD7#None:U8#None", true, true, true, true);
    			api.Data.Calculate("F#None:O#Forms:A#targetAccount:UD2#None:U4#None:UD5#None:U6#None:UD7#None:U8#None = RemoveZeros($srcFinancial)",null,null,null,null,"UD1#Product.Base",null,"UD3#Location.Base",null,null,null,null,null,null,true);
    		}
    		#endregion

    Try this and run against Target cube from DM.

  • pranav46's avatar
    pranav46
    Contributor II
    		#region Pull Cashflow from Financial
    		private void Cash_Pull_from_Financial(SessionInfo si, FinanceRulesApi api)
    		{
    			//Simple Data Pull
    			DataBuffer sourceDB = new DataBuffer();
    			sourceDB = api.Data.GetDataBufferUsingFormula("cb#Financial:S#ACTUAL:C#Local:F#None:O#Forms:A#SourceAccount:UD2#None:U4#None:UD5#None:U6#None:UD7#None:U8#None");
    			api.Data.FormulaVariables.SetDataBufferVariable("srcFinancial", sourceDB, true);
    				
    			api.Data.ClearCalculatedData("F#None:O#Forms:A#RateAccount:UD2#None:U4#None:UD5#None:U6#None:UD7#None:U8#None", true, true, true, true);
    			api.Data.Calculate("F#None:O#Forms:A#targetAccount:UD2#None:U4#None:UD5#None:U6#None:UD7#None:U8#None = RemoveZeros($srcFinancial)",null,null,null,null,"UD1#Product.Base",null,"UD3#Location.Base",null,null,null,null,null,null,true);
    		}
    		#endregion

    Try this and run against Target cube from DM.