Skip to main content
January 17, 2022
Solved

How do I get a dim name (dimpk) from a dim ID?

  • January 17, 2022
  • 2 replies
  • 0 views

Hi all

Onestream stores a lot of information using an integer ID instead of a name. And most of the time we also deliver a simple way, to get objects (or names of objects) using an api or brapi call.

Somehow getting the name of a dimension from its ID is an exception. Is there a simple way to do it?

Cheers

 

Best answer by ChristianW

I came up with some simple code to do so, do you know even simpler once?

BRAPI:

Dim aDimID As Integer = 0 
Dim aDimName As String = BRApi.Finance.Dim.GetDim(si, New DimPk(dimtypeid.Scenario, aDimID)).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

aDimName = ""
aDimName = brapi.Finance.Dim.GetDims(si, dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

and

Api:

Dim aDimID As Integer = 0 
Dim aDimName As String = api.Dimensions.GetDim(New DimPk(dimtypeid.Scenario, aDimID)).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

aDimName = ""
aDimName = api.Dimensions.GetDims(dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

Cheers

2 replies

ChristianWAuthorAnswer
January 17, 2022

I came up with some simple code to do so, do you know even simpler once?

BRAPI:

Dim aDimID As Integer = 0 
Dim aDimName As String = BRApi.Finance.Dim.GetDim(si, New DimPk(dimtypeid.Scenario, aDimID)).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

aDimName = ""
aDimName = brapi.Finance.Dim.GetDims(si, dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

and

Api:

Dim aDimID As Integer = 0 
Dim aDimName As String = api.Dimensions.GetDim(New DimPk(dimtypeid.Scenario, aDimID)).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

aDimName = ""
aDimName = api.Dimensions.GetDims(dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name

brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")

Cheers

January 17, 2022

Getting DimPk works the same, here one sample:

Dim aDimID As Integer = 0 
Dim aDimPK As Dimpk = api.Dimensions.GetDim(New DimPk(dimtypeid.Scenario, aDimID)).DimPk

aDimPK = api.Dimensions.GetDims(dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).DimPk
January 24, 2022

Hi Christian!

To return names of the dimensions this is what I figured out:

Dim DimName As String = OneStream.Shared.Common.MemberType.GetName(GetType(MemberType), DimTypeId)

Hernan

January 29, 2022

Hi Hernan

Very interesting code sample, I will need to invest some more time in it, but unfortunately, it doesn't give back the dimension name but the DimType's name.

Thanks and cheers

Christian