BPC Script logic for Dummies? (Part 2)
What if user wants to scope members based on a specific property value?
For example, a user wants to filter Account dimension members those are Asset.
To achieve this, we need to use ACCTYPE property which has the type value of account.
AST is the value for ASSET account. (Note: Value is based on the APSHELL of BPC.)
The command is *XDIM_FILTER.
The usage is *XDIM_FILTER <DIMENSIONNAME> = [DIMENSIONName].Properties(“Property name”) = “Property value”
So above example can be written as below.
*XDIM_FILTER ACCOUNT = [account].properties(ACCTYPE=’AST’)
Let’s say Account dimension has 3 members as below.
ID ACCTYPE
Extsales INC
CASH AST
TAXES EXP
NETINCOME INC
Then *XDIM_FILTER_ACCOUNT will select CASH member only.
Let’s assume If you already used multiple *XDIM_MEMBERSET command and below are selected data from the fact tables.
*XDIM_MEMBERSET TIME = 2011.JAN
*XDIM_MEMBERSET CATEGORY = BUDGET
<Result>
EXTSALES , 2011.JAN, BUDGET, 9000
CASH , 2011.JAN, BUDGET, 3000
TAXES , 2011.JAN, BUDGET, 800
NETINCOME, 2011.JAN, BUDGET, 1500
Now if you add *XDIM_FILTER against ACCOUNT dimension.
*XDIM_MEMBERSET TIME = 2011.JAN
*XDIM_MEMBERSET CATEGORY = BUDGET
*XDIM_FILTER ACCOUNT = [account].properties(ACCTYPE?=’AST’)
Then only one record will be selected from above result because CASH is the only account member that has ‘AST’ value of ACCTYPE property.
<Result>
CASH , 2011.JAN, BUDGET, 3000
We just figured out how to scope the source data based on the property.
Then someone might ask this question.
“Can we scope based on the value?
The command is *XDIM_GETMEMBERSET. Unlike other command,
*XDIM_GETMEMBERSET {dimension} [={member set}]
[*APP={application}] //optional
[*XDIM_MEMBERSET {dimension} [={member set}] //as many of these as needed
[*QUERY_TYPE= 0 | 1 | 2] //optional
*CRITERIA {expression} //required
*ENDXDIM
*XDIM_GETMEMBERSET P_CC=[P_CC].[H1].[AAPJ].CHILDREN
*APP=PLANNING
*XDIM_MEMBERSET P_DataSrc=INPUT
*CRITERIA [P_ACCT].[H1].[CE0001000]>1000
*ENDXDIM
It will get data those are..
a. Children member of AAPJ in the P_CC dimension. AND
b. from the PLANNING application AND
c. INPUT member of P_Datasrc dimension AND
d. CE0001000 member’s value of the P_ACCT dimension should be greater than 100000
Let’s Assume Fact table has below records.
CE0001000, 2011.JAN, ACTUAL, INPUT, KOREA , 2500
CE0002000, 2011.JAN, ACTUAL, INPUT, CHINA , 5000
CE0001000, 2011.JAN, ACTUAL, ADJ , CHINA , 3000
CE0002000, 2011.JAN, ACTUAL, INPUT, JAPAN , 1999
CE0003000, 2011.JAN, ACTUAL, INPUT, JAPAN , 2222
CE0001000, 2011.FEB, BUDGET, ADJ , KOREA , 345
CE0001000, 2011.FEB, BUDGET, INPUT, TURKEY, 1999
CE0003000, 2011.JAN, ACTUAL, INPUT, TURKEY, 1100
CE0001000, 2011.FEB, BUDGET, INPUT, CHINA , 1050
CE0001000, 2011.FEB, BUDGET, INPUT, JAPAN , 450
Which records will be selected?
The answer is
CE0001000, 2011.JAN, ACTUAL, INPUT, KOREA, 2500
CE0001000, 2011.FEB, BUDGET, INPUT, CHINA, 1050
Below records will not be selected even though P_ACCT is CE0001000
because its value is less than 1000
or Datasrc is not INPUT
or it is not the child member of AAPJ (Asia Pacific)
CE0001000, 2011.JAN, ACTUAL, ADJ , CHINA , 3000 (datasrc is not input)
CE0001000, 2011.FEB, BUDGET, ADJ , KOREA , 345 (datasrc is not input)
CE0001000, 2011.FEB, BUDGET, INPUT, TURKEY, 1999 (Turkey is not child member of AAPJ)
CE0001000, 2011.FEB, BUDGET, INPUT, JAPAN , 450 (Value is less than 1000)
Here are some important Notes for using this command.
Note 1: This command works only for BPC MS.
Note 2: if you don’t specify each dimension’s scope, it will be performed in the corresponding
members of the pre-selected region which is defined with XDIMMEMBERSET of previous line or
Passed by Data Manager.
Note 3: This command will generate MDX statement so it takes more time to execute.
if your dataset has only base members, you can use *XDIM_GETINPUTSET. (please refer help file)
In that case user defines as below.
For example, IN BPC NW, *XDIM_MEMBERSET = BAS(US),CANADA will not work.
Therefore, we should use *XDIM_MEMBERSET and *XDIM_ADDMEMBERSET.
But… what if your dimension members are updated frequently?
As I know, almost every customer updates their dimension at least once a month.
You can use *Filter but sometimes it may not work all the time.
The Variable is defined using % symbol.Here are some examples, %MYTIME% , %CUR% etc.
Both of them is scope command but *SELECT will be faster because it will create SQL statement.
Here is the grammar of both commands.
SELECT ID from mbrCurrency where [GROUP] = ‘REP’
After it executes above SQL command, all result will be saved into %REPORTING_CURRENCIES% variable.
Here is an example of *MEMBERSET which will make same result but execute MDX statement instead of SQL.
*MEMBERSET(%REPORTING_CURRENCIES%, Filter{[CURRENCY].members, [currency].properties(GROUP=’REP’)})
The variable can be used anywhere in the logic, like in this example:
*XDIM_MEMBER_SET CURRENCY=%REPORTING_CURRENCIES%
ID GROUP
EUR REP
KRW
JPY
*XDIM_MEMBER_SET CURRENCY = USD,EUR
Note: MEMBERSET command is only supported by MS version.
This is a great blog series. Thanks for writing it!
One comment - on the last example, you talk about the *MEMBERSET keyword, but don't mention that it is only supported on the MS platform. It would be good to add this 🙂
Cheers,
Ethan
I will post a document about the comparision of BPC script command between NW and MS. One of my colleague asked it so I searched it before but I could not find it.
Regards,
James Lim.
if the * SELECT and *MEMBERSET are the same what syntax that could be used to do the following:
*SELECT (%MES%,[MESES],TIME,[ID] = '%TIME_SET%')
I am using BPC 7.0 MS.
It's better to move this document to BPC MS space, here it's very confusing because most of the discussed examples are applicable to MS version only.