2 Replies Latest reply: Sep 14, 2018 2:07 PM by Neelam Sehrawat RSS

    Make use of existing variable with new condition

    Vivian Kta

      Hi all,

       

      I have a repeated expression which I put as a variable:

      vAmt=sum({<Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"}>}[Import Value])
      
      
      

       

      Then I have a very similar expression, just one more condition :

      sum({<Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"},[Wholesales/Retail]={'Retail'}>}[Import Value])
      
      
      

       

      Is it possible to make use of the above variable (vAmt) to combine with modifier [Wholesales/Retail]={'Retail'} in the second expression? I'm not sure how the modifier should be nested or what syntax should be. Appreciate any help.

        • Re: Make use of existing variable with new condition
          Felip Drechsler

          Hi Vivian,

           

          It depends actually, what kind of behaviour do you need?

          If you want to get different expressions for differente graphs, something like this might work, but you'll need to check your condition.

           

          vAmt=sum({<$(vSetAnalysis)>}>}[Import Value]) 

           

          Create another variable with something like this:

          vSetAnalysis=if(GetObjectField(0)='Dimension Field Name',Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"},[Wholesales/Retail]={'Retail'},Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"})


          That should set the vSetAnalysis to the second expression you need when your first dimension used on the chart is called 'Dimension Field Name'.

          Otherwise, it gets the first expression.

          • Re: Make use of existing variable with new condition
            Neelam Sehrawat

            You can also create a variable as vSum = sum({<Month_Year={"$(=date(makedate(max(Year),1),'MMM YY'))"}, $1>}[Import Value])

            and pass the value of $1 while using the variable like

            =$(vSum([Wholesales/Retail]={'Retail'}))