Forum Discussion

Satyapal77's avatar
Satyapal77
New Contributor
1 day ago

Business Rule: Copy data from one cube to another with different cube dimensions

Hello,

I have following two cubes in onestream:

  1. Volumes
  2. Detail

All the cube dimensions are the same except for UD1. For volumes, UD1 cube dimension is VintageDim and for detail its FunctionTotal.

I am trying to copy data from "Volumes" cube to "Detail" Cube through a Business Rule. I am running this business rule from Data Management Step. The rule runs perfectly but it doesn't copy the data. I don't get any error too. Please can someone help to understand the issue?

Public Sub CopyData() 
    Try
        'Define the source and target information
Dim sourceCube As String = "Volumes"
Dim targetCube As String = "Detail"
Dim sourceScenario As String = api.Pov.Scenario.Name
 
'1. Pull data from the source cube (Volumes)
'Using a formula to capture the desired data unit
Dim sourceDb As DataBuffer = api.Data.GetDataBufferUsingFormula($"Cb#{sourceCube}:S#{sourceScenario}:A#Product_Sales")
 
'2. Convert the data buffer to match the target cube's dimensionality
'This handles the automatic mapping of extended members between the cubes
Dim convertedDb As DataBuffer = api.Data.ConvertDataBufferExtendedMembers(targetCube, sourceScenario, sourceDb)
 
'3. Set the converted data into the target cube (Detail)
Dim destInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("")
api.Data.SetDataBuffer(convertedDb, destInfo)
 
 
    Catch ex As Exception
        brapi.ErrorLog.LogMessage(si, "EXCEPTION: " & ex.Message)
        Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    End Try
End Sub

 

Thank you

 

1 Reply

  • sameburn's avatar
    sameburn
    Icon for OneStream Employee rankOneStream Employee

    If you log the Target Buffer (before you set it) does it contain expected results? I would also recommend starting with a small data set while developing your logic and including Entity and Time dimensions in your Source Buffer retrieve based on Data Unit variables passed into your Custom Calculate via DM... also log both Source and Target buffers before setting (to ensure you are only setting expected results)

    Once ready to set the results, please ensure that you mark the data as durable in the SetDataBuffer method (if that is the intention)

    e.g. api.Data.SetDataBuffer(convertedDb, destInfo,,,,,,,,,,,,, True)

    Hope this helps

    Sam