Question: Is it Possible to Extract Data with Time Periods in Columns?

kmd
Contributor

I know we can use the Matrix setting in our Data Sources to import data where time periods are in the columns (i.e. M1, M2, M3, M4, M5 M6 etc.).


Is anyone out there aware of a way to extract data out of OS in the same type of format (time periods in columns); either by way of a DM step or any other way?

1 ACCEPTED SOLUTION

ChristianW
Valued Contributor

Here it is:

 

Dim dtObj As DataTable = BRApi.Import.Data.FdxExecuteDataUnitTimePivot(si, "Equipment Division", "E#NAE.Base", "Local", ScenarioTypeId.Budget, "S#Forecast3p9", "T#2023.base", "Periodic", False, True, "", 4, False)
Dim csvText As New Text.StringBuilder()

For Each drObj As DataRow In dtObj.Rows
	
	For Each dcObj As DataColumn In dtObj.Columns
		csvText.Append(drObj(dcObj.ColumnName))
		csvtext.Append(",")
	Next	
	csvText.AppendLine
Next

Dim folderName As String = "Documents/Public/Csv"
Dim fileName As String = "CsvFile.csv"
Dim csvFileInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, fileName, folderName)
Dim csvFileObj As New XFFile(csvFileInfo, String.Empty, Text.Encoding.UTF8.GetBytes(csvText.ToString))
csvFileObj.FileInfo.ContentFileExtension = "csv"
					
Dim folderObj As New XFFolder(FileSystemLocation.ApplicationDatabase, folderName)
BRApi.FileSystem.InsertOrUpdateFolder(si, folderObj)
BRApi.FileSystem.InsertOrUpdateFile(Si, csvFileObj)

 

It will save the file in "Documents/Public/Csv/"

And here the functions details:

Dim dt As DataTable = BRApi.Import.Data.FdxExecuteDataUnitTimePivot(si, cubeName, entityMemFilter, consName, scenarioTypeId, scenarioMemFilter, timeMemFilter, viewName, suppressNoData, useGenericTimeColNames, filter, parallelQueryCount, logStatistics)

View solution in original post

4 REPLIES 4

ChristianW
Valued Contributor

Yes, with some of the FDX commands you can export data to a datatable with time in the columns:

BRApi.Import.Data.FdxExecuteDataUnitTimePivot

Oh thank you so much!!  Coding is not my area of expertise - I don't suppose you have an example?

ChristianW
Valued Contributor

Here it is:

 

Dim dtObj As DataTable = BRApi.Import.Data.FdxExecuteDataUnitTimePivot(si, "Equipment Division", "E#NAE.Base", "Local", ScenarioTypeId.Budget, "S#Forecast3p9", "T#2023.base", "Periodic", False, True, "", 4, False)
Dim csvText As New Text.StringBuilder()

For Each drObj As DataRow In dtObj.Rows
	
	For Each dcObj As DataColumn In dtObj.Columns
		csvText.Append(drObj(dcObj.ColumnName))
		csvtext.Append(",")
	Next	
	csvText.AppendLine
Next

Dim folderName As String = "Documents/Public/Csv"
Dim fileName As String = "CsvFile.csv"
Dim csvFileInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, fileName, folderName)
Dim csvFileObj As New XFFile(csvFileInfo, String.Empty, Text.Encoding.UTF8.GetBytes(csvText.ToString))
csvFileObj.FileInfo.ContentFileExtension = "csv"
					
Dim folderObj As New XFFolder(FileSystemLocation.ApplicationDatabase, folderName)
BRApi.FileSystem.InsertOrUpdateFolder(si, folderObj)
BRApi.FileSystem.InsertOrUpdateFile(Si, csvFileObj)

 

It will save the file in "Documents/Public/Csv/"

And here the functions details:

Dim dt As DataTable = BRApi.Import.Data.FdxExecuteDataUnitTimePivot(si, cubeName, entityMemFilter, consName, scenarioTypeId, scenarioMemFilter, timeMemFilter, viewName, suppressNoData, useGenericTimeColNames, filter, parallelQueryCount, logStatistics)

Thank you SO much for this!!!!