3 Replies Latest reply: Nov 30, 2015 8:43 AM by Sunny Talwar RSS

    How to raname variables in a function

    Beatriz Manjón

      Hello all,

       

      I have a doubt when renaming  variables regarding a function in my main script:

       

      I have a formula which calculates the number of periods in a year within 4 weeks in each period :

       

      rangemin(ceil(Week (FECHAQV)/ 4),13)as Period,

       

      The problem comes when I have renamed this periods(1,2,3.....until 13), into 'text'( Week 1-4,Week 5-8,etc). In the table box, these periods are shown correctly but in the current selection box and in my dimensions are shown with NUMBER and I want to show them as my text defined previosly.

       

      Capture1.PNGCapture2.PNGCapture3.PNG

       

      So my question is, is there any possibility to rename this periods not in a ''Label'' if not in the main script in order to appear these variables as my text wanted?

       

      Thanks in advance,

        • Re: How to raname variables in a function
          Sunny Talwar

          Is it a table box or list box you are talking about which displays week 9 -12? What is the exact expression you are using, you can use the similar expression in the script

          • Re: How to raname variables in a function
            Beatriz Manjón

            Hello Sunny,

             

            Yes indeed,it is a List Box where I use editing the expression:

             

            if( Period='1','Week 1-4',if (Period='2','Week 5-8', if ( Period='3', 'Week 9-12',if ( Period='4', 'Week 13-16',if ( Period='5', 'Week 17-20',if ( Period='6', 'Week 21-24',if ( Period='7', 'Week 25-28',if ( Period='8', 'Week 29-32',if ( Period='9', 'Week 33-36',

            if ( Period='10', 'Week 37-40',if ( Period='11', 'Week 41-44',if ( Period='12', 'Week 45-48',if ( Period='13', 'Week 49-53',if ( Period='14', 'Week 54-54',Period))))))))))))))

             

             

            But if I use these conditions in my main script it doesnt work; The error says Field not found <Period>

             

            rangemin(ceil(Week (FECHAQV)/ 4),13)as Period,

                 

                  if( Period='1','Week 1-4',if (Period='2','Week 5-8', if ( Period='3', 'Week 9-12',if ( Period='4', 'Week 13-16',if ( Period='5', 'Week 17-20',if ( Period='6', 'Week 21-24',if ( Period='7', 'Week 25-28',if ( Period='8', 'Week 29-32',if ( Period='9', 'Week 33-36',

            if ( Period='10', 'Week 37-40',if ( Period='11', 'Week 41-44',if ( Period='12', 'Week 45-48',if ( Period='13', 'Week 49-53',if ( Period='14', 'Week 54-54',Period)))))))))))))),

               

            So I guess that condition doesn't work in the script.

              • Re: How to raname variables in a function
                Sunny Talwar

                Try doing it in a preceding load or resident load:

                 

                Preceding Load Option

                LOAD Period,

                if( Period='1','Week 1-4',if (Period='2','Week 5-8', if ( Period='3', 'Week 9-12',if ( Period='4', 'Week 13-16',if ( Period='5', 'Week 17-20',if ( Period='6', 'Week 21-24',if ( Period='7', 'Week 25-28',if ( Period='8', 'Week 29-32',if ( Period='9', 'Week 33-36',

                if ( Period='10', 'Week 37-40',if ( Period='11', 'Week 41-44',if ( Period='12', 'Week 45-48',if ( Period='13', 'Week 49-53',if ( Period='14', 'Week 54-54',Period)))))))))))))) as NewPeriod;

                LOAD rangemin(ceil(Week (FECHAQV)/ 4),13) as Period

                FROM SourceFile;


                Resident Load Option

                Table1:

                LOAD rangemin(ceil(Week (FECHAQV)/ 4),13) as Period

                FROM SourceFile;


                Table2:

                LOAD *,

                          if( Period='1','Week 1-4',if (Period='2','Week 5-8', if ( Period='3', 'Week 9-12',if ( Period='4', 'Week 13-16',if ( Period='5', 'Week 17-20',if ( Period='6', 'Week 21-24',if ( Period='7', 'Week 25-28',if ( Period='8', 'Week 29-32',if ( Period='9', 'Week 33-36',

                if ( Period='10', 'Week 37-40',if ( Period='11', 'Week 41-44',if ( Period='12', 'Week 45-48',if ( Period='13', 'Week 49-53',if ( Period='14', 'Week 54-54',Period)))))))))))))) as NewPeriod

                Resident Table1;


                DROP Table Table1;