14 Replies Latest reply: Jun 5, 2012 8:22 AM by swuehl RSS

Rangemax in script

Sivaraj Seeman

Hi,

I am trying  to use rangemax,Chart level its working but in script its not working

Any idea...

 

Sivaraj S

  • Rangemax in script
    jagan mohan

    Hi Sivaraj,

     

    Try this sample script.

     

    Years:

    LOAD

        RangeMax(Year, Sales) AS MaxValue,

        *;

    LOAD * INLINE [

        Year, Sales

        2005, 10000

        2006, 200

        2007,30000

        2008,400

        2009,500

        2010,600

        2011,70000

        2012,800

    ];

     

    Hope this helps you.

     

    Regards,

    jagan.

    • Rangemax in script
      Sivaraj Seeman

      Its giving all value in the field

      • Rangemax in script
        jagan mohan

        Hi,

         

        RangeMax() receives multiple values as parameters and returns max value among those parameters.

         

        RangeMax(Year, Sales) AS MaxValue

         

        For record 1 in above script, the 2 parameters are 2005, 10000.  Among this two 10000 is the maximum value, so it returns 10000.  Like wise this function works for all the records.

         

        Regards,

        Jagan.

        • Rangemax in script
          Sivaraj Seeman

          What the following example gives result in script

           

          rangemax(1,2,3,4)

           

          can u test this

          • Rangemax in script
            jagan mohan

            Hi Sivaraj,

             

            The result is 4, because 4 is the max value among all values.

             

            Regards,

            Jagan.

          • Rangemax in script
            Celambarasan Adhimulam

            Hi,

                 It will give you 4?For you its not working like that?

             

            Celambarasan

          • Rangemax in script
            jagan mohan

            Hi,

             

            Try this script

             

            Test:

            LOAD

            rangemax(1,2,3,4)  AS Test

            AutoGenerate 1;

             

            Regards,

            Jagan.

            • Rangemax in script
              Sivaraj Seeman

              in sript it gives result like

              1

              2

              3

              4

              • Rangemax in script
                jagan mohan

                Hi,

                 

                Can you post the script which you used.

                 

                Regards,

                jagan.

                • Rangemax in script
                  Sivaraj Seeman

                  LOAD

                       *,

                  RANGEMAX(a,b,c,d,e) as TEXT ; // each field has single value

                   

                  resident tmp;

                   

                  TEXT getting all the values

                  • Rangemax in script
                    jagan mohan

                    Hi,

                     

                    If a, b, c, d and e are fields, then RANGEMAX(a,b,c,d,e) will return the maximum value among those values for each record.

                     

                    RANGEMAX(a,b,c,d,e) as TEXT

                     

                    I didn't understand about this "TEXT getting all the values", if you do not want a, b, c, d, e fields then just use following script

                     

                    LOAD

                         RANGEMAX(a,b,c,d,e) as TEXT

                     

                    resident tmp;

                     

                    Regards,

                    Jagan.

                  • Rangemax in script
                    swuehl

                    So a,b,c,d and e are fields in your tmp table, right?

                     

                    What are the values of all these fields? You mentioned that you got

                    1

                    2

                    3

                    4

                     

                    returned for the RANGEMAX(a,b,c,d,e) function. So these are the first four values of your TEXT field?

                    Could you post the first four complete lines for your table, including TEXT and a,b,c,d,e?

                     

                    Are all your values numericals or are you coping with text values? You might want to consider using rangemaxstring(a,b,c,d,e) as TEXT

                    then.

                     

                    It would be best if you could post a small sample app that demonstrates what you are trying to achieve and your issue. If this is not possible, please provide a sufficient snippet of your script and some sample data (input to your code snippet / output table).

                    • Re: Rangemax in script
                      Sivaraj Seeman

                      Hi sweuhl,

                      I guess rangemax is not working because of data stored in qvd is below format

                       

                       

                      ABCDEF
                      0.06640670.22879810.34169960.33348350.06075390.3978605
                      0
                      0.0839515
                      0
                      0.2428004
                      0
                      0.2099772
                      0
                      0.1059254
                      0
                      0.0761975
                      0
                      0.1439361


                      i am using for loop to get values based on customer

                      for 1st loop i giving correct value if it goes to 2nd further its storing like the table above

                      Can you suggest me on this

                      • Rangemax in script
                        swuehl

                        You are using for loop to get values based on customer?

                         

                        Are the above table fields the only fields in your table? I guess you need to have at least one more field, your dimension (maybe customer)?

                         

                        If so, you could try using a group by load

                         

                        Result:

                        LOAD Dimension,

                        Rangemax(sum(A),sum(B),sum(C),sum(D),sum(E),sum(F)) as RangeMax

                        resident YourTable group by Dimension;