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 file.
We have a Parser BR that is called on each of the 12 data columns that looks at the first field in each record to get the year and concatenates that with the M<number> month for each month column to give the correct Time dimension member in which to store the data. e.g. 2023M1
The problem is we're getting the row header "Fiscal Year" instead of the year value in the record, so the string being returned looks like Fiscal YearM1
How do we get the year data from the first column instead of the column header?
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As ParserDimension, ByVal args As ParserArgs) As Object
Dim fiscalYear As String() = {"Oct","Nov","Dec""Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep"}
Dim YearColPosition As Integer = 0
Dim year As String = String.Empty
Dim month As String = String.Empty
Try
'Both of these keep giving us the column header "Fiscal Year"
'instead Of the value In the currently parsed record
year = api.Parser.DelimitedParsedValues(YearColPosition)
'year = args.Line.Split(",")(YearColPosition)
'this marries the index of the month name in the months array
'with M to give us the M1 notation for period.
month = $"M{Array.IndexOf(fiscalYear, args.Value)+1}"
BRApi.ErrorLog.LogMessage(si, $"Time: {year}{month}")
Return $"{year}{month}"
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
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.
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.