How to get Base Members of UD Dimension into a Variable

BSK
New Contributor III

Could you please provide a sample script with example  to Generate the base mambers of UD2 dimension into a Variable.

I'm trying to follow the below syntax, but it's not working for UD Dimensions

Dim baseMembers As List(Of Member) = api.Members.GetBaseMembers(entityDimPk, entityId, Nothing)

Appreciate your assistance.

2 ACCEPTED SOLUTIONS

JackLacava
Community Manager
Community Manager

A Member object is not a String object. You loop on the objects, and use properties out of them. Example:

 

Dim U3Filter As List(Of Member) = api.Members.GetBaseMembers( _
               api.Pov.UD3Dim.DimPk, api.Members.GetMemberId(dimtype.UD3.Id, "TopUD3"))

For Each memberObj In U3Filter
     ' memberObj.Name is an actual String
     BRApi.ErrorLog.LogMessage(si, memberObj.Name)
next

 

(Btw, looping on lists of members should not be done in member formulas or calculation rules; ideally you want to use DataBuffers with filters and Formula Variables. I strongly recommend picking up the OneStream Finance Rules and Calculations Handbook to find out how and why.)

View solution in original post

ChrisLoran
Valued Contributor

This is fine for Data Unit dimensions (like Entity , for example), as the opening post suggested.


Just a warning for any others coming across this thread and tempted to re-use snippets.
Only do this if you are going to loop through Data Unit dimension types (mainly Entity, Time etc).


If anyone is thinking of re-using this concept to loop through Accounts/UD members, and if you're going to work with data, and use things like GetDataCell, SetDataCell, api.Data.Calculate, then please do not do this inside your iteration loop. This usually causes huge performance problems and we have had several customer escalations due to poor performance caused by business rules that loop through Account/Flow/UD members and perform calculations in the loop.

For iterating through base Accounts/UDs, consider using a DataBuffer to loop through the stored cells, instead of looping through many dimension members which may/may not have any stored data to actually process. 

edit: [ I just realized Jack already warned this 2h ago.  oops, so a bit of a duplicate post ]

View solution in original post

6 REPLIES 6

Andreas
New Contributor

hi BSK,

This is for a UD2 memberlist:

api.Members.GetBaseMembers(api.Pov.UD2Dim.DimPk, api.Members.GetMemberId(dimtype.UD2.Id, "Top_Gaap_SY"))

BSK
New Contributor III

Thanks Andreas.

I have difined this as below and looping into For  loop, But getting the error as "1) Error at line 44: Value of type 'Member' cannot be converted to 'String'."  or " Value of type 'String' cannot be converted to 'DimPk'."

----

Dim U3Filter As List(Of Member) = api.Members.GetBaseMembers(api.Pov.UD3Dim.DimPk, api.Members.GetMemberId(dimtype.UD3.Id, "TopUD3"))

For Each UD2 As String In U3Filter

----

JackLacava
Community Manager
Community Manager

A Member object is not a String object. You loop on the objects, and use properties out of them. Example:

 

Dim U3Filter As List(Of Member) = api.Members.GetBaseMembers( _
               api.Pov.UD3Dim.DimPk, api.Members.GetMemberId(dimtype.UD3.Id, "TopUD3"))

For Each memberObj In U3Filter
     ' memberObj.Name is an actual String
     BRApi.ErrorLog.LogMessage(si, memberObj.Name)
next

 

(Btw, looping on lists of members should not be done in member formulas or calculation rules; ideally you want to use DataBuffers with filters and Formula Variables. I strongly recommend picking up the OneStream Finance Rules and Calculations Handbook to find out how and why.)

BSK
New Contributor III

Thanks jack, I have already got the book, In progress of reading.

ChrisLoran
Valued Contributor

This is fine for Data Unit dimensions (like Entity , for example), as the opening post suggested.


Just a warning for any others coming across this thread and tempted to re-use snippets.
Only do this if you are going to loop through Data Unit dimension types (mainly Entity, Time etc).


If anyone is thinking of re-using this concept to loop through Accounts/UD members, and if you're going to work with data, and use things like GetDataCell, SetDataCell, api.Data.Calculate, then please do not do this inside your iteration loop. This usually causes huge performance problems and we have had several customer escalations due to poor performance caused by business rules that loop through Account/Flow/UD members and perform calculations in the loop.

For iterating through base Accounts/UDs, consider using a DataBuffer to loop through the stored cells, instead of looping through many dimension members which may/may not have any stored data to actually process. 

edit: [ I just realized Jack already warned this 2h ago.  oops, so a bit of a duplicate post ]

Agreed with Chris, typically you try to use a filters within a api.data.calculate.