4 Replies Latest reply: Nov 27, 2011 10:42 AM by the fourth RSS

    Sum in Script with Set Analysis

      Hi, i don't understand why if i have this script:

       

      Data:

      Load

      *

      Inline [

          Quantity, REGION, ID

          2 , A , 1

          2 , A , 2

          2 , A , 3

          2 , B , 4

          2 , B , 5

      ];

       

      Let vFilter = '=maxstring(REGION)';

      Let vSum1 = '=Sum({$<REGION = {"=$(vFilter)"}>} Quantity)';

      Let vSum2 = '=Sum({$<REGION = {B}>} Quantity)';

       

      vSum1 = 0

      but

      vSum2 = 4

       

       

      is there any way to do the Sum using the result of variable vFilter?

      p.d. I know it is possible using "Group By", but this time i need it using like explain

       

      Thanks in advance

        • Sum in Script with Set Analysis
          Liron Baram

          hei

           

           

           

          the problem you have is that the second varaible implent the first one as is writen

           

          try this  script

           

           


          Data:

          Load

          *

          Inline [

          Quantity, REGION, ID
          2 , A , 1
          2 , A , 2
          2 , A , 3
          2 , B , 4
          2 , B , 5
          ]
          ;



          Let vFilter ='=maxstring(REGION)';

          Let vSum1 ='= Sum({$<REGION = {"' & chr(36) &'(vFilter)"}>} Quantity)';