5 Replies Latest reply: Dec 15, 2014 3:41 AM by Jonathan Dienst RSS

    variable LET script error

      Hello! Can someone explain me, please, why does

       

      LET vMonthStart=MonthStart(max(Date));

      //Date is a field of previously loaded table

      cause a script line error?

      Regards,

      Alexa

        • Re: variable LET script error
          Anand Chouhan

          It seems correct statement check the date format of Date field

           

          try for check

           

          =MonthStart(max(Today()))

           

           

          Regards

          Anand

            • Re: variable LET script error

              Anand, thak you for your answer!

              I tried to fix it..

              With code like this

              TempTable1:

              LOAD

              Max( Date) as MaxDate

              Resident FACT;

              Let vMaxDateNum = Num( Peek( 'MaxDate', 0, 'TempTable1'));

              Let vMaxDate = Date( $(vMaxDateNum));

              LET vMonthStart=MonthStart(FieldValue('MaxDate', 1));

              LET vPeriod=$(vMaxDate)-$(vMonthStart);

               

               

              I get another  error "script line error LET vPeriod=08.12.2014-01.12.2014"

            • Re: variable LET script error
              Jonathan Dienst

              Hi

               

              Let evaluates the statement on the RHS before assigning it to the variable. Max(Date) is not a legal statement in script mode outside of a LOAD, so this statement is causing an error.

               

              Your error in the second post - you need quotes around the date variables:

               

              LET vPeriod='$(vMaxDate)'-'$(vMonthStart)';


              HTH

              Jonathan

                • Re: variable LET script error

                  Hello,Jonathan! thanks for explanation!!

                  I made it as you wrote. Now I dont get an error? but it doesnt calculate Period=(

                  TempTable1:

                  LOAD

                  Max( Date) as MaxDate

                  Resident FACT;

                  Let vMaxDateNum = Num( Peek( 'MaxDate', 0, 'TempTable1'));

                  Let vMaxDate = Date( $(vMaxDateNum));

                   

                  TempTabl2:

                  Load MonthStart(FieldValue('MaxDate', 1)) as MonthStart,

                  MonthEnd(FieldValue('MaxDate', 1)) as MonthEnd

                  resident TempTable1;

                   

                  Let vMonthStartNum = round(Num( Peek( 'MonthStart', 0, 'TempTable2')));

                  Let vMonthEndNum= round(Num( Peek( 'MonthEnd', 0, 'TempTable2')));

                   

                  LET vPeriod='$(vMaxDateNum )'-'$(vMonthStartNum)';

                  LET vDaysMonth='$(vMonthEndNum)'-'$(vMonthStartNum)';

                   

                  with code like this thats what I see

                    • Re: variable LET script error
                      Jonathan Dienst

                      Hi

                       

                      You have changed the definition of the two variables to numbers, so you no longer need expansions and quotes. I think you have a trailing space in the Let vPeriod statement that is causing your problem

                       

                      Simplify these two statements to:

                       

                      LET vPeriod = vMaxDateNum - vMonthStartNum;

                      LET vDaysMonth = vMonthEndNum - vMonthStartNum;

                       

                      HTH

                      Jonathan