Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

How can I convert numbers to months (i.e. 1 = January)

Hello,

New to Qlikview... please can someone tell me how I can convert numbers to months to that 1 is displayed as Jan, 2 as Feb etc. I have a listbox with the numbers 1 - 12 in - so how can I convert the numbers to text and still retain the functionality?

Thanks,

markp3rry.

Tags (2)
1 Solution

Accepted Solutions
MVP
MVP

How can I convert numbers to months (i.e. 1 = January)

Hi,

Create a Mapping table as below

MonthMapping:

LOAD * INLINE [

MonthNo, Month

1, Jan

2, Feb

3, Mar

4, Apr

'

'

'

'

];

Now use Month field wherever you need.

Note: Your Month number Field name and above month number field should be same.  In the above script I used MonthNo.  So you replace it with your month field name, so that the two tables will join.

Regards,

Jagan.

14 Replies
erich_shiino
Honored Contributor

How can I convert numbers to months (i.e. 1 = January)

Hi,

There are some alternatives here:

http://community.qlik.com/message/1895#1895

Regards,

Erich

jykang0638
New Contributor III

How can I convert numbers to months (i.e. 1 = January)

You can write a expression to convert number to months in the listbox properties window.
Open listbox properties window and then choose <expression> at the Field in the General tab.
Write expression like below at the Edit Expression window.
=Pick(monthnum, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
Here, monthnum is the your fileld name.


I hope it will help you.
Steve Kang.

MVP
MVP

How can I convert numbers to months (i.e. 1 = January)

Hi,

Create a Mapping table as below

MonthMapping:

LOAD * INLINE [

MonthNo, Month

1, Jan

2, Feb

3, Mar

4, Apr

'

'

'

'

];

Now use Month field wherever you need.

Note: Your Month number Field name and above month number field should be same.  In the above script I used MonthNo.  So you replace it with your month field name, so that the two tables will join.

Regards,

Jagan.

Not applicable

How can I convert numbers to months (i.e. 1 = January)

Thanks - I tried Steve and Jagan's methods. Both worked, but I was unable to sort Steve's solution in date order (i.e. Jan to Dec). Jagan's answer sorted perfectly on Load Order.

Not applicable

Re: How can I convert numbers to months (i.e. 1 = January)

Hi

you can Create a bucket in the Script(Back/Front).for converting no into string.functionality will remaining as it is   

=if(Month=1,'jan',

        if(Month=2,'Feb',

              if(Month=3,'March',

                    if(Month=4,'April',

                          if(Month=5,'May',

                                if(Month=6,'June',

                                           if(Month=7,'July',

                                                           if(Month=8,'August',

                                                                 if(Month=9,'Septem',

                                                                      if(Month=10,'OCT',

                                                                            if(Month=11,'Nov',

                                                                                 if(Month=12,'DEC'))))))))))))

                

Employee
Employee

How can I convert numbers to months (i.e. 1 = January)

All the above will work. But I would generate it on the fly using

Month(MakeDate(2012,MonthNo))

/HIC

Luminary
Luminary

Re: How can I convert numbers to months (i.e. 1 = January)

Thanks Henric. This is very useful.

Cheers,

DV

martynlloyd
Contributor III

Re: How can I convert numbers to months (i.e. 1 = January)

Thanks Henric, very elegant, just what I need.

Marty.

rcorcoran
Contributor

Re: How can I convert numbers to months (i.e. 1 = January)

Hi Jagan

I have tried your solution and it works but it is bringing back all the Months whether data is loaded for a month or not.  I only have  2014 and only have Jan data but all months are showing is there a way around this?  If I have the numbers it will only show 1 even though there is nothing selected

Thanks

Rhona

Community Browser