Skip to Content
I explained basic 3 parts of script logic in the last post. It was Scoping, Calculation and writing.
We will find out more advanced features for scoping In this post.

1. Scope using member property

      We found how to use *XDIM_MEMBERSET last time.
      *XDIM_MEMBERSET is for scoping based on the member ID.
      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

2. Scope using member value
      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?
      For example, can we select all data that an account value greater than 100?
      Of course, we can do it.
      The command is *XDIM_GETMEMBERSET. Unlike other command,
      it needs  *ENDXDIM command to specify data.
      Here is the grammar of XDIM_GETMEMBERSET and an example.

      *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)

3. When user wants to add more members on top of current scoped data.

      Let’s say a user wants to add USASales entity on top of predefined memberset.
      In that case user defines as below.
      *XDIM_ADDMEMBERSET Entity = USASales
      The main reason why we need this is
          a. Sometimes XDIMMEMBERSET doesn’t work with some specific functions like BAS(parent).
             For example, IN BPC NW,  *XDIM_MEMBERSET = BAS(US),CANADA will not work.
             Therefore, we should use *XDIM_MEMBERSET and *XDIM_ADDMEMBERSET.
           
              *Note: In BPC MS, BAS() will not work with XDIM_MEMBERSET.
          b. if user always wants to run a specific memberset whenever logic runs,
               should use XDIM_ADDMEMBERSET

4. Dynamic Scope and saving it to a variable.
      Sometimes we need to save our scoped data into a script logic variable.
      But… what if your dimension members are updated frequently?
      As I know, almost every customer updates their dimension at least once a month.
      If customer changes their dimension members, what will happen in your script logic?
      You can use *Filter but sometimes it may not work all the time.
      Then we can use *SELECT and *MEMBERSET command as a dynamic scope tool.
      Like other script engine, Logic script also supports Variable to save some data.
      The Variable is defined using % symbol.Here are some examples, %MYTIME% , %CUR% etc.
      So how can we save some data into the variable and when it can be used?
      Usually, the variable can be filled using *SELECT command and *MEMBERSET command.
      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 (, {member set in MDX format})

      Let’s see how to use *SELECT command.
           *SELECT(%REPORTING_CURRENCIES%, “ID”, “CURRENCY”, “[GROUP] = ‘REP’”)
      This command will get the ‘member ID(what)’ from the ‘currency dimension(From)’ that the
      GROUP property has the value ‘REP’ (where).
      Actually, it will create a SQL statement as below

           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%

      Let’s assume Currency dimension has below members.

          ID           GROUP

         USD            REP
         EUR            REP
         KRW          
         JPY
      Then above statement will be converted as
                     
                        *XDIM_MEMBER_SET CURRENCY = USD,EUR 
      When you define and fill in data using *SELECT and *MEMBERSET,
      please remember this as ‘MEMBERSET Variable’
    
      Note: MEMBERSET command is only supported by MS version.

We reviewed key command of scoping today.
We will review advanced calculation command and control command like *IF or *FOR – *NEXT in the next post.
If you have questions or want to know something about it, please leave a comment.
Thank you.
To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Ethan Jewett
    Hi James,

    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

    (0) 
    1. James Lim Post author
      Thank you for comment. 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.

      (0) 
  2. Alan Valenzuela

    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.

    (0) 
  3. Vadim Kalinin

    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.

    (0) 

Leave a Reply