4 Replies Latest reply: Jul 11, 2012 4:30 PM by andrepeter RSS

    How to give Range in Inline?

      Hi,

       

      I need to create below bands for new variable

       

      Variable Value range, Bandvalue for table

      0 to 9    , <10

      10 to 20, 10 - 20

      21 to 30, 21-30

      30 to 40, 30-40

      > 40 , 40 +

       

      I know how to use Inline now, but I don't know to use inline with variable value range.

       

      I don't want to code long script as below example

       

      Load * inline

      [

      Value, Band

      0,<10

      1,<10

      2,<10 ....

      ]

       

      Any advice?

        • Re: How to give Range in Inline?
          Mayil Vahanan Ramasamy

          Hi,

           

               Try this,

           

              In script,

           

          Let vEnd = 50;

          Let vStart = 0;

           

          Generate:
          LOAD ($(vStart) + IterNo()-1) AS Value AutoGenerate 1
          While ($(vStart) + IterNo()-1) <= $(vEnd);

           

          T1:
          Load * , if(Value < 10 , '<10', if(Value >= 10 and Value <=20 , '10-20',if(Value > 20 and Value <=30,'21-30',if(Value >= 30 and Value <=40,'30-40', '>40')))) As Band
          Resident Generate;

           

          Hope it helps

          • Re: How to give Range in Inline?

            Trying to put my question with example. How to code this Age_Range in efficient way?

             

             

            Trial:
            LOAD   Name,
                    Age,
                 Seller,
                 origin

            From
            Sample.xls

            Join

            Load * inline
            [
              Name,Type
              Orange,Fruit
              Wheat,Crop
              Rice,Crop
              Apple,Fruit 
              Grapes,Fruit

            Join

            Load * inline     
            [
              Age,Age_Range

               0, 0 days
               1, 1 Days
               2, 2 to 5 Days
               3, 2 to 5 Days
               5, 2 to 5 Days
               6, 6 to 15 Days 
               7, 6 to 15 Days
            .
            .
            .
            .
               31, 31 to 60 Days 
            .
            .
            .
            .
               61, 61 to 90 Days 
              
            ]

              • Re: How to give Range in Inline?
                Mayil Vahanan Ramasamy

                HI,

                 

                  Trial: 

                LOAD 

                Name,

                        Age,

                     If( Age = 0, '0' , if(Age =1 , '1', if(Age >1 and Age < 6, '2 to 5' , if( Age > 5 and Age < 16, '6 to 15' , if(Age >15 and Age< 31, '15 to 31' , if(Age > 30 and Age < 61, '31 to 60', '61 to 90')))))) & ' Days' as Agefilter,

                Seller,

                     origin 

                From
                Sample.xls;

                 

                Join(Trial)

                Load * inline
                [
                  Name,Type
                  Orange,Fruit
                  Wheat,Crop
                  Rice,Crop
                  Apple,Fruit 
                  Grapes,Fruit
                ] ;

                 

                Hope it helps

              • Re: How to give Range in Inline?

                Thanks a lot. It worked perfectly for me.