02-17-2023 01:14 AM - last edited on 05-02-2023 09:59 AM by JackLacava
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.
Solved! Go to Solution.
02-17-2023 08:51 AM - edited 02-17-2023 08:52 AM
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.)
02-17-2023 11:14 AM - edited 02-17-2023 11:16 AM
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 ]
02-17-2023 02:27 AM - edited 02-17-2023 02:28 AM
hi BSK,
This is for a UD2 memberlist:
api.Members.GetBaseMembers(api.Pov.UD2Dim.DimPk, api.Members.GetMemberId(dimtype.UD2.Id, "Top_Gaap_SY"))
02-17-2023 04:32 AM
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
----
02-17-2023 08:51 AM - edited 02-17-2023 08:52 AM
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.)
02-20-2023 05:07 AM
Thanks jack, I have already got the book, In progress of reading.
02-17-2023 11:14 AM - edited 02-17-2023 11:16 AM
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 ]
02-20-2023 05:30 AM
Agreed with Chris, typically you try to use a filters within a api.data.calculate.