Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

anavin33
New Contributor II

Sorting Month-Year by Month Name

In my chart, the data is all correct but my dimension is not sorting correctly.

=if(date(renewal_dt) <= date(GetFieldSelections(prod_dt))+182.5 and month(renewal_dt) <> month(GetFieldSelections(prod_dt)), month(renewal_dt) &' '& year(renewal_dt),

if(renewal_dt > GetFieldSelections(prod_dt), year(renewal_dt),))

This is the dimension. It displays the next six months and then after that, just the years, based on whatever production date is chosen. Attached is a snapshot of how the dimension is displayed when I sort just numerically and have 10/31/15 selected as the production date.

The years are in the correct order but the Months are not and that is what I am struggling with

1 Solution

Accepted Solutions

Re: Sorting Month-Year by Month Name

Can you try this as your calculated dimension instead?

=If(Date(renewal_dt) <= Date(GetFieldSelections(prod_dt)) +182.5 and Month(renewal_dt) <> Month(GetFieldSelections(prod_dt)), MonthName(renewal_dt),

If(renewal_dt > GetFieldSelections(prod_dt),

Dual(Year(renewal_dt), Year(renewal_dt) * 100)))

12 Replies
vsudhakar
Contributor III

Re: Sorting Month-Year by Month Name

in sort tab to sort the in expression or have the option in the other options also

krishnacbe
Valued Contributor III

Re: Sorting Month-Year by Month Name

Hi,

Sort using expression option in the Sort Tab. Create a inline table to make the order and use it in the sort tab.

anavin33
New Contributor II

Re: Sorting Month-Year by Month Name

What would the inline table look like, if you dont mind?

krishnacbe
Valued Contributor III

Re: Sorting Month-Year by Month Name

Inline should be like below. you need to map the month column with your month column and then sort based on MonthID

LOAD * INLINE [
MonthID, Month
1, Jan
2, Feb
3, Mar
4, Apr
5, May
6, Jun
7, Jul
8, Aug
9, Sep
10, Oct
11, Nov
12, Dec
]
;

Re: Sorting Month-Year by Month Name

Can you try this as your calculated dimension instead?

=If(Date(renewal_dt) <= Date(GetFieldSelections(prod_dt)) +182.5 and Month(renewal_dt) <> Month(GetFieldSelections(prod_dt)), MonthName(renewal_dt),

If(renewal_dt > GetFieldSelections(prod_dt),

Dual(Year(renewal_dt), Year(renewal_dt) * 100)))

anavin33
New Contributor II

Re: Sorting Month-Year by Month Name

This did not work

Re: Sorting Month-Year by Month Name

Would you be able to elaborate what it did? Did not work is not useful and doesn't tell me what I might have done incorrectly

anavin33
New Contributor II

Re: Sorting Month-Year by Month Name

It changed nothing, the columns rows stayed the same. I even messed with the sort and still nothing changed.

Re: Sorting Month-Year by Month Name

So after you used this, you did use the numerical sort order and it still did not work? Would you be able to share a sample?

Community Browser