Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
nihhalmca
Specialist II
Specialist II

Month sort order at edit script

Hi All,

I have a Date field (YYYYMM) in fact table and i derived Year and Month fields from Date field in fact table.

need to present Month sort order in UI like Jan, Feb ------, as of now it showing like Apr, Aug -----

have to do sort order at edit script (not at UI).

I have tried dual and applymap functions.

Dual scenario: Month contains 24 fields (12 as text and 12 as number) and no changes if i join dual table with fact as well.

Applymap scenario: I need to do resident or preceding load.

Thanks,

Nihhal.

Labels (1)
1 Solution

Accepted Solutions
tresB
Champion III
Champion III

Derive you month field or other date fields using proper date functions (rather than any string function) like:

Date(Date#(YourDateText, 'YYYYMM')) as Date,

Month(Date#(YourDateText, 'YYYYMM')) as Month,

...


Then all fields sort should work fine.

View solution in original post

13 Replies
sunny_talwar
MVP
MVP

Are you creating Month like this?

Month(DateField)?

If you are, then you can just use numeric sort because Month() function created a dual field which does have a underlying numeric value associated with it

tresB
Champion III
Champion III

Derive you month field or other date fields using proper date functions (rather than any string function) like:

Date(Date#(YourDateText, 'YYYYMM')) as Date,

Month(Date#(YourDateText, 'YYYYMM')) as Month,

...


Then all fields sort should work fine.

nihhalmca
Specialist II
Specialist II
Author

Hi Tresesco, thanks.

nihhalmca
Specialist II
Specialist II
Author

Hi Sunny,

I have done this way.

Date format like YYYYMM

Date(Date#(Date,'YYYYMM'),'YYYY-MM') as Date,

Right(Date(Date#(Date,'YYYYMM'),'MMM'),3) as Month,

Right(Date(Date#(Date,'YYYYMM'),'YYYY'),4) as Year,

Month(Date) did not give result as expected.

sunny_talwar
MVP
MVP

May be try this

Month(Date#(Date,'YYYYMM')) as Month

nihhalmca
Specialist II
Specialist II
Author

Hi Tresesco,

Month names are showing right side in filter pane as number.

Sort order goes wrong If i use Text(Month).

nihhalmca
Specialist II
Specialist II
Author

Hi Sunny.

Month names are showing right side in filter pane as number.

Sort order goes wrong If i use Text(Month).

sunny_talwar
MVP
MVP

Why are you using Text(Month) my friend? I am not sure I understand the reason for using Text() function?

tresB
Champion III
Champion III

If this is only for the sake of alignment, you can adjust that from presentation tab like:

Untitled.png