4 Replies Latest reply: Feb 11, 2012 2:50 AM by Celambarasan Adhimulam RSS

    How do I re-order the x axis of a chart?

      I have a chart where the x axis is weekdays, and I want to put it in order ie. Mon. Tues. Wed.  Right now I only know how to sort by alphabetical (A->Z), or y axis.  Is there an expression that will let me change it so it is chronological?

        • How do I re-order the x axis of a chart?
          Dennis Hoogenboom

          This depends on your data.

          Try sort it on load order.

          • How do I re-order the x axis of a chart?
            Jason Michaelides

            I'm not able to open Chandashok's qvw on my iPad so I don't know if this solution's already been presented...

             

            To expand on Dennis's suggestion, one way to sort string values in a desired order is to preload the order in the script.  QlikView stores each field in its own memory table and distinct values are concenated as they are loaded. In this example, you should load the day of the week in an inlne table at the top of your script then drop it at the end. Something like:

             

            Weekdays:

            LOAD * INLINE [

            Weekday

            Mon

            Tues

            Wed

            Thurs

            Fri

            Sat

            Sun

            ];

             

            Data:

            LOAD

              Field1,

              Field2,

              Field3,

            .

            .

            .

              Weekday,

            .

            .

            .

            FROM....;

             

            DROP TABLE Weekdays;

             

            Now, in your chart on the sort tab, promote Weekday to the top and check the box to sort by Load Order.

             

            NOTE: The field name "Weekday" in the inline table must be EXACTLY the same as the field name from the main data load.

             

            Hope this helps,

             

            Jason

            • How do I re-order the x axis of a chart?
              Celambarasan Adhimulam

              Hi,

                   Create a weekday field using dual function like

              LOAD

                        Dual(WeekDayString, WeekDayNum) AS WeekDay

              INLINE [

                  WeekDayNum, WeekDayString

                  1, Mon

                  2, Tue

                  3, Wed

                  4, Thur

                  5, Fri

                  6, Sat

                  7, Sun

              ];

              Use sort by Numeric value as ascending or descending whatever way you want.It will order the weekday day field based on the WeekDayNum order.

              This should be before the other table with the week day field load.

               

              Hope it helps

              Celambarasan