Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Order Stacked chart by date field.

Hi, I've tried to Sort Stacked chart by date field. Using "numeric Ascending"

Date field is displayed as "May 2009".."Apr 2009"... etc..

However it does not change it's order.

I would like to keep the display as "MMM YYYY" but still have it sorted.

Any help?

Tried:

=



date(a, 'MMM YYYY')

and also:

=

month(a) & ' ' & Year(a)





12 Replies
Anonymous
Not applicable
Author

I just posted a Wiki "How to create a Calendar" - http://community.qlik.com/wikis/qlikview-wiki/how-to-create-a-calendar.aspx
Maybe it will reduce the amount of questions on that topic (wishful thinking...)

Not applicable
Author

OK,

So the way I got round it, was to load the data in order using ORDER BY in the sql statement.

johnw
Champion III
Champion III

That works, but isn't "The QlikView Way". It seems to me that either we don't understand your problem, or you don't understand our solutions.

QlikView dates are stored internally as the number of days since 12/30/1899. But QlikView gives you lots of options for how you display the dates, including "May 2009". If you use QlikView dates rather than some other date format, you can then use all of QlikView's date manipulation functions, everything shows up ordered correctly, and life is generally easier. You should use QlikView dates.

Here's an example of turning numeric dates into QlikView dates and months. The first format string tells it the format of the input number, the second tells it the format you want to see in QlikView by default (can be overridden on charts). And attached is an application using this exact script, then doing a stacked bar chart by month with the months in order. So far as I understand, that's what you want. It does not require sorting the input data. It only requires using the right format for your dates.

LOAD
date(date#(Date,'YYYYMMDD'),'DD/MM/YY') as Date
,date(monthstart(date#(Date,'YYYYMMDD')),'MMMM YYYY') as Month
,pow(10,rand()*3) as Sales
,pick(ceil(rand()*2),'Company A','Company B') as Customer
INLINE [
Date
20081201
20090522
20090505
20090413
20090108
20090220
20081215
20090221
20090317
20090316
];