Using parameters in FilterByPattern
Posted: Thu Feb 11, 2021 7:41 pm
Hi All,
I am attempting to use parameter value (pVersion) in filters to create a dynamic subsets in temporary view. I have no idea how to do this. This is my meager attempt, that as expected did not work. Any advice would be appreciated.
For broader context: I have a cube consisting of 3 dimensions: V_Version (v1 - v12), T_Cas_M (Months 1-12) and M_Sales. I am attempting to export specific version using AsciiOutput. The idea is to prompt users to enter parametr pVersion and then use that value to filter source view. The whole code is as follows:
Prolog
Data:
I am attempting to use parameter value (pVersion) in filters to create a dynamic subsets in temporary view. I have no idea how to do this. This is my meager attempt, that as expected did not work. Any advice would be appreciated.
Code: Select all
sVersionFilter ='{TM1FILTERBYPATTERN( {TM1SUBSETALL( [V_Version] )}, pVersion)}';
Prolog
Code: Select all
sSourceCube = 'Sales';
sSourceView = 'TMP_Sales';
sDimVersion = 'V_Version';
sDimCas = 'T_Cas_M';
sDimSales = 'M_Sales';
nTempFlag = 1;
OutputFile1 = 'D:\TM1SHARE\08_Outputs\07_ECP2_KONSOLIDACE\Sales.txt';
OutputFile2 = 'D:\TM1SHARE\08_Outputs\07_ECP2_KONSOLIDACE\Sales_Months_Inc.txt';
#___________________Zdrojové_View_________________;
# Vytvoří filtery pro subsety - leaf elements
sVersionFilter ='{TM1FILTERBYPATTERN( {TM1SUBSETALL( [V_Version] )}, "pVersion")}';
sCasFilter ='{TM1FILTERBYLEVEL( {TM1SUBSETALL( [T_Cas_M] )}, 0)}';
sSalesFilter ='{TM1FILTERBYLEVEL( {TM1SUBSETALL( [M_Sales] )}, 0)}';
# Vytvoří subsety pro view pomocí vytvořených filterů
SubsetCreateByMDX(sSourceView, sVersionFilter, nTempFlag);
SubsetCreateByMDX(sSourceView, sCasFilter, nTempFlag);
SubsetCreateByMDX(sSourceView, sSalesFilter, nTempFlag);
# Vytvoří Zdrojové View
ViewCreate(sSourceCube, sSourceView, nTempFlag);
ViewSubsetAssign(sSourceCube, sSourceView, sDimVersion, sSourceView);
ViewSubsetAssign(sSourceCube, sSourceView, sDimCas, sSourceView);
ViewSubsetAssign(sSourceCube, sSourceView, sDimSales, sSourceView);
# Přiřadí pravidla pro View
ViewExtractSkipZeroesSet(sSourceCube, sSourceView, 1);
ViewExtractSkipCalcsSet(sSourceCube, sSourceView, 1);
ViewExtractSkipRuleValuesSet( sSourceCube, sSourceView, 1 );
DataSourceNameForServer = sSourceCube;
DataSourceNameForClient = sSourceCube;
DatasourceCubeview = sSourceView;
DataSourceType = 'VIEW';
Code: Select all
AsciiOutput(OutputFile1, vsVersion, vsSales, Value);
AsciiOutput(OutputFile2, vsVersion, vsMonth, vsSales, Value);