The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
RobbSalzmann
3 years agoValued Contributor II
Unable to get value from another column in Parser BR
OneStream V7.0.1 We have a Data Source that takes data file that has 12 data columns Oct ... Sep. The year for the data in the 12 data columns is a field "Fiscal Year", the first column of the data...
- 3 years ago
This approach should work
- add a new Source Dimension for Time of type "Matrix DataKey Text".
- change that data type to "DataKey Text" and assign it to the Fiscal Year column
- modify the rule above to just return M1, M2, etc.
The result should automatically concatenate year and period for the exploded records.
- 3 years ago
This and the following code in a BR called by each of the month columns solved for this requirement. Thanks JackLacava ckattookaran and franciscoamores for all the considerations.
ckattookaran
3 years agoValued Contributor
I think I've this rule somewhere 🤣🤣 I was not happy with the split the rule and then go by the index. I've to look this up and see if I still have it somewhere where you can lookup a value by giving the column header.
ckattookaran
3 years agoValued Contributor
It was a struggle to remember where it was. Luckily I thought of blogging about it and found it in my drafts. (almost a year later 🤣)
Dim dimensionKey As String = String.Empty
Using dbConn As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
' Layout name is nothing but the name of the data source
Dim dbwIDParserWheres As New List(Of DbWhere) From {New DbWhere("LayoutName", DbOperator.IsEqualTo, "SalesPlanning_Temp")}
Dim layoutKey As String = BRApi.Database.LookupRowFieldValue(si, "App", "ParserLayouts", dbwIDParserWheres, "UniqueID", "")
' we need to get the dimension key from the parserdimensions table
' key for the sorteddictonary is as follows
' datatype\displayorder\dimensionname
If Not String.IsNullOrEmpty(layoutKey)
Dim dbwParserDimWheres As New List(Of DbWhere) From {New DbWhere("LayoutKey", DbOperator.IsEqualTo, layoutKey), New DbWhere("DimensionName", DbOperator.IsEqualTo, "Ic")}
dimensionKey = BRApi.Database.LookupRowFieldValue(si, "App", "ParserDimensions", dbwParserDimWheres, "Concat(Concat(Concat(Concat(DimensionDataType, '\'),DisplayOrder), '\') , DimensionName)", "")
End If
End Using
' get IC dimension of current line, location is mapped to IC
Dim icDim As ParserDimension = api.Parser.Dimensions.Item(dimensionKey)
Dim locationCode As String = icDim.Value
I've updated it to use the DbWhere clause.
- franciscoamores3 years agoContributor II
Hi Celvin,
dimension keys and all other parser layout details is also available in the transformer object.
Api.Parser.Dimensions is a dictionary which has ParserDimension as value. In that object I think we can find all details for the line being processed.
There is also api api.Parser.GetFieldValuesForSourceDataRow(si As SessionInfo, rowID As Guid) wew you can pass the rowID to get a dictionary with all values from source row. RowID is stored in the ParserDimension object.
- ckattookaran3 years agoValued Contributor
Yes it does. You can see that almost to the end of the code. The code above is to get the key if the ParserDimension. Now the Gersource one needs a guid and to get the guid, you need the same dance.
- franciscoamores3 years agoContributor II
Sure but I mean you don't need to query the database as that information is already in the Parse object.
api.Parser.Dimensions will have all keys.
We used similar approach to get all data source entries for source id:
Dim parserDimSourceIdKeys As List(Of String) = objTransformer.Parser.Dimensions.Keys.Where(Function(x) x.EndsWith("si")).ToList
- RobbSalzmann3 years agoValued Contributor II
I like the possibility of this: api.Parser.GetFieldValuesForSourceDataRow(si As SessionInfo, rowID As Guid)
I prefer to keep the logic in the single BR than spread it out over other columns.- ckattookaran3 years agoValued Contributor
Not sure what you mean by keeping it in the same BR, the code above is going to go. I'm not sure how you can get the row guid.
- JackLacava3 years ago
OneStream Employee
That might work, but I would argue that the performance implications of doing two expensive db calls on every single record might give you issues at scale.
- ckattookaran3 years agoValued Contributor
It is true. Unless there is a way to add that to globals and get it from there.
- franciscoamores3 years agoContributor II
You can put in globals but I think all details needed in the parser BR should be available via api (ParserDimension object) and args (ParserArgs)
Related Content
- 5 months ago
- 2 years ago