4 Replies Latest reply: Feb 13, 2017 8:31 AM by Joe Easley RSS

    Variables within Variables

    Joe Easley

      Good Morning All!

      I have a use case for embedding variables within another variable to determine limits on gauges. 

      take the following variables:

       

      vInvLmtClientA:

      If(([Bnfi Nn Client])= 'ClientA', 600,

        0

       

      vInvLmtClientB:

      If(([Bnfi Nn Client])= 'ClientB', 15000,

        0

       

      vInvLmtClientC:

      If(([Bnfi Nn Client])= 'ClientC', 10000,   

        0

       

      The above variables define the max allowable open transactions for a given client.

       

      I would like a variable that evaluates the selection in [Bnfi nn Client] and gives the SUM of the defined limit for the selection, and if no selection has been made, the limit should be assuming that ALL clients are selected. 

       

      Thank you ALL!!

        • Re: Variables within Variables
          Marcus Sommer

          Maybe you could use something like this:

           

          pick(wildmatch(getfieldselections([Bnfi Nn Client]), 'ClientA', 'ClientB', 'ClientC', '*'), 600,15000,10000,25600)

           

          and only if there is a multiple usage of this expression it made sense to use a variable for it.

           

          - Marcus

            • Re: Variables within Variables
              Joe Easley

              so i tried this, and i'm not getting the expected result.  when i select ClientA and ClientB, the upper limit sets to 25600, instead of 15600. not sure if i entered the expression incorrectly or if i didnt properly explain what i was trying to do.  It may be that what i want is not possible.

                • Re: Variables within Variables
                  Marcus Sommer

                  My suggestion is only a short version and it could be extended for it, for example:

                   

                  pick(wildmatch(getfieldselections([Bnfi Nn Client]),

                       'ClientA', 'ClientB', 'ClientC', 'ClientA, ClientB', 'ClientA, ClientC', 'ClientB, ClientC', '*'),

                       600,15000,10000,15600,10600,25000,25600)

                   

                  whereby it made it obvious that this logic is quite expensive and if there are more selection-possibilties it would be more suitable to create an own field for these factors and then just using: sum(factor) for it.

                   

                  - Marcus