Forum Discussion

Marco's avatar
Marco
Contributor II
2 days ago

How can I remove empty values from GetDataBuffer and obtain the entity with Text1, Text2, Text3?

Hi Everyone.

I would like to know how I can remove zero values in my GetDataBufferUsingFormula.

Dim DatabufferCalc As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(E#" & strParentEntity & ".Base,E#XFMemberProperty(DimType=Entity, Member=|!PerformPnL_Entity!|, Property=Text1).Base:S#[" & strScenario & "]:T#" & strPeriod & ":O#Top:I#None:U1#ALL_DEPARTMENTS:U2#ALL_PRODUCTS:U3#CORP_RPT:U4#ALL_PROJECTS:U5#None:U6#None:U7#None:U8#None,A#411000)")

And from the result, I would like to obtain the entity, and from that entity, know its Text1, Text2, and Text3. However, for now, I see that I can only obtain the account and the rest of the properties such as the UD

Dim DatabufferCalc As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(E#" & strParentEntity & ".Base,E#XFMemberProperty(DimType=Entity, Member=|!PerformPnL_Entity!|, Property=Text1).Base:S#[" & strScenario & "]:T#" & strPeriod & ":O#Top:I#None:U1#ALL_DEPARTMENTS:U2#ALL_PRODUCTS:U3#CORP_RPT:U4#ALL_PROJECTS:U5#None:U6#None:U7#None:U8#None,A#411000)")
api.Data.FormulaVariables.SetDataBufferVariable("DatabufferCalc", DatabufferCalc, True)
For Each sourceCell As DataBufferCell In DatabufferCalc.DataBufferCells.Values
  'I would like to obtain the entity and Texts
   Dim account As String = sourceCell.DataBufferCellPk.GetAccountName()
   BRApi.ErrorLog.LogMessage(si)
Next

 

3 Replies

  • rhankey's avatar
    rhankey
    Contributor II

    A Databuffer holds data for a Data Unit, who's key is Cube, Entity, Parent, Scenario, Time & Cons.  So, you aren't going to find Entity in the rows of the Databuffer, which contains some or all of a DataUnit.  You can see what is in a DataBuffer for yourself with the following sample command:

    DataBufferCalc.LogDataBuffer(api,"contents of databuffer",100)

    If you want the data for multiple entities, you will need to get a separate DataBuffer for each entity.

    As for getting the Text properties for an entity member, take a look at api.Entity.Text().

    To pre-remove Zeros or NoData as you wish when you get a DataBuffer you can use RemoveZeros() or RemoveNoData() as follows.  The RemoveZeros can be done before or after the filtering:

    api.Data.GetDataBufferUsingFomrula("FilterMembers(RemoveZeros(A#NetInc),[some filter])")

    Of course, you can skip over the zeros or NoData when cycling through your DataBuffer.

    Lastly, the FilterMembers() function you show makes no sense, as you are providing a filter in your first parameter.  The first parameter is supposed to specify the intersection to which you want to apply the filtering, which is specified in the subsequent parameters.

    • Marco's avatar
      Marco
      Contributor II

      Hi Rhankey.

      I do not want to obtain the Text1 of the entity from the POV. Instead, for example, I want to obtain the entities of an element based on the BR and get the Text1 of those entities whose names I have. Regarding the removal of zeros or no data, I appreciate your help. As for obtaining the entities, I want to get the entities under another entity, but for now, I am not exactly sure how to do it

      • rhankey's avatar
        rhankey
        Contributor II

        There are two variations of the api.Entity.Text() function.  One variant takes no parameters, and will operate on the POV entity.  The second version allows you to specify any Entity member.  Much the same as all the other api.[DimTypeName].Text() functions do too.

        You need to be very careful when getting Cube data from a different entity, of for more than one entity, as the currencies for those entities could differ.  And in many instances, those entities may not share the same cube and thus could have different dimensionality.  In addition to that, when getting children of an entity, you can find that the sum of the children<>the parent due to things like eliminations unless you consider very carefully what data you get from the cube.