2 Replies Latest reply: Sep 8, 2010 5:49 AM by Marcus Malinow RSS

    Set Analysis based on condition

      Hi,

      I'm trying to use a variable to control a set analysis operation.

      Currently my variable vSetPortfolio contains the expression

      %Key_MatterPartner={'$(=Only(UserKey))'}

      What I'd like to do is instead of always setting %Key_MatterPartner, is conditionally set either %Key_MatterPartner or another field %Key_MatterExec based on the selected value in my Rank field. So, if Rank is 'Partner' use %Key_MatterPartner={'$(=Only(UserKey))'} otherwise use %Key_MatterExec={'$(=Only(UserKey))'}

      So far I have tried this:

      if(Rank='Partner',%Key_MatterPartner={'$(=Only(UserKey))'},%Key_MatterExec={'$(=Only(UserKey))'})

      however this seems to set both %Key_MatterPartner AND %KeyMatterExec at the same time.

      Help!

      Marcus

        • Set Analysis based on condition
          Miguel Angel Baeyens de Arce

          Hello Marcus and welcome to the Forums,

          As you already have a variable for each case, you may add in your set analysis a new variable (say, vSetAnalysis) which is populated with one of the existing, based on a selected field, triggered by a button or something:

           

          Sum({< $(vSetAnalysis) >} Amount)


          where vSetAnalysis will have

           

          %Key_MatterPartner = {'$(=Only(UserKey))'}


          Hope that helps

            • Set Analysis based on condition

              Hi Miguel,

              thanks for your help.

              What I tried was setting up two variables to contain each of my conditions,

              so:
              vSetPartnerPortfolio = %Key_MatterPartner={'$(=Only(UserKey))'}
              vSetAssociatePortfolio = %Key_MatterExec={'$(=Only(UserKey))'}

              Then a macro to set a third variable to one of these dependant on the users' rank.

              set rank = ActiveDocument.Fields("Rank").GetOptionalValues

              set vSetPortfolio = ActiveDocument.GetVariable("vSetPortfolio")
              set vSetAssociatePortfolio = ActiveDocument.GetVariable("vSetAssociatePortfolio")
              set vSetPartnerPortfolio = ActiveDocument.GetVariable("vSetPartnerPortfolio")

              if rank.count=1 and rank.item(0).Text = "Associate" then
              vSetPortfolio.SetContent vSetAssociatePortfolio.GetContent.String, true
              else
              vSetPortfolio.SetContent vSetPartnerPortfolio.GetContent.String, true
              end if

              Not quite as elegant as I was hoping, my preference would have been just to have an if condition in my vSetPortfolio variable, but it seems to work just fine.

              Marcus