网格中groovy脚本中的新行[PBCS oracle]

mlnl4t2r  于 2023-06-28  发布在  Oracle
关注(0)|答案(1)|浏览(156)

我需要添加一个新列来过滤'rowmbr1'的部分文本并将其放置在新列中。
示例:
rowmbr1的值为“Sales staff”或“Marketing staff”
在输出csv中,我需要在rowmbr1旁边添加一个新列,仅包含文本“Sales”或“Marketing”

我的脚本没有新列:

def povDims = [ Povdim1, povdim2]
def povMbrs = [['Povmbr1'], ['povmbr2']]
def colDims =  ['coldim'] 
def colMbrs = [ ['coldim1','coldim2'] 
def rowDims = ['rowdim']
def rowMbrs = [ ['rowmbr1']]

 
Cube cube = operation.application.getCube("Plan")
DataGridDefinitionBuilder builder = cube.dataGridDefinitionBuilder()
builder.setSuppressMissingBlocks(true)
builder.setSuppressMissingRows(true)
builder.addPov(povDims, povMbrs)
builder.addColumn(colDims, colMbrs)
builder.addRow(rowDims, rowMbrs)

DataGridDefinition gridDefinition = builder.build()

cube.loadGrid(gridDefinition, false).withCloseable {
grid ->

  //def filteredRows = grid.rows.findAll{it.data.findAll{it.name() == 'Territory'}}

    operation.exportDataToFile(grid, 'fullGridExport.csv')
    }

非常感谢您的帮助。
示例:
rowmbr1的值为“Sales staff”或“Marketing staff”
在输出csv中,我需要在rowmbr1旁边添加一个新列,仅包含文本“Sales”或“Marketing”
我无法在导出CSV之前创建新列。

roejwanj

roejwanj1#

我不是EssBase或EPMMaven,但您需要创建一个从动态表达式获取值的列。下面是一些例子:

String memberFunc = """StrToMbr( CASE [rowdim].CurrentMember
   WHEN [rowdim].[Sales staff] THEN "Sales"
   WHEN [rowdim].[Marketing staff] THEN "Marketing"
   ELSE "" 
)"""

Dimension members = operation.application.getDimension("Measures")
members.saveMember(Member: memberFunc, Name: "Departments" )

def rowDims = [ '[Measures].[Departments]' ]

在MDX中,我认为它更简单:

with member [Measures].[Departments] as
  StrToMbr( CASE [rowdim].CurrentMember
     WHEN [rowdim].[Sales staff] THEN "Sales"
     WHEN [rowdim].[Marketing staff] THEN "Marketing"
     ELSE "" 
  )
  select [column1].Members on Columns
         [Measures].[Departments] on Rows
  where
       [PovDim1].[Member1], [PovDim2].[Member2], ...

API并没有给予如何从MDX转换为API的很多细节,但我已经尽了最大努力。

相关问题