2 Replies Latest reply: Apr 29, 2016 6:14 PM by Sunny Talwar RSS

    Firstsortedvalue with load order

    David Capan

      Hello,

       

      Is it possible to use a field in the firstsortedvalue function with a weight of it's load order?

       

      Thank you in advance.

        • Re: Firstsortedvalue with load order
          Sunny Talwar

          If you have created a field like RowNo() as Key, you should be able to use Key as a load order. Is this what you were looking for, or did I mis-understand?

          • Re: Firstsortedvalue with load order
            Sunny Talwar

            Another option is to use the Aggr() functions load order capability here. (This wouldn't require any modification in the script)

             

            Script

             

            Table:

            LOAD * Inline [

            Country, Value

            India, 10

            India, 15

            India, 12

            India, 16

            USA, 12

            USA, 30

            USA, 4

            USA, 49

            USA, 2

            China, 23

            China, 40

            ];

             

            Greens are the last value by load order and Red are the first value by load order

             

            Straight table

             

            Dimension

            Country

             

            Expression

            1) =FirstSortedValue(Value, -Aggr(RowNo(TOTAL), Value, Country)) -> Green Values

            2) =FirstSortedValue(Value, Aggr(RowNo(TOTAL), Value, Country)) -> Red Values

             

            Capture.PNG