Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Convert months (numeric) into text

Hi Experts

I have a file that contains months in a numeric format. How can I convert the numeric values into text for the months? (Jan, Feb, e.g.)

Thank you for your help!

Jan

Tags (1)
1 Solution

Accepted Solutions
preminqlik
Valued Contributor II

Re: Convert months (numeric) into text

Load *,

text(Date(Date#(fieldname,'MM'),'MMM'))               as               MonthName

from path;

11 Replies
Not applicable

Re: Convert months (numeric) into text

Hi jan,

In your load script you set the date format = MON/DD/YYYY;

For Month kindly use MON i hope it would help you to convert.. try it.

Regards,

Vignesh

Re: Convert months (numeric) into text

month(MakeDate(2000,YourNUmberFiled))

buzzy996
Honored Contributor II

Re: Convert months (numeric) into text

try to use MONTH(UR FIELD NAME)

Not applicable

Re: Convert months (numeric) into text

Depending on what you're tying to do, you can also use:

pick(your_field_name, 'JAN', 'FEB', 'MAR, ...., 'NOV', 'DEC');

This is assuming your_field_name is a number between 1 and 12.

Regards!

MVP
MVP

Re: Convert months (numeric) into text

you can use

subfield('$(MonthNames)', ';', yourmonthnumber)

also in the script, example

load

  rowno() as Month,

  subfield('$(MonthNames)', ';', rowno()) as MonthName

AutoGenerate 12;

1.jpg

MonthNames is defined at the beginning of the script

Employee
Employee

Re: Convert months (numeric) into text

Another one:

if your values are  1,2,3 etc....

use an expression like this to interpret the numbers as months and then display them in 'mmm' format ( 'Jan','Feb','Mar' ....)

Date(Date#(MonthNumber,'M'),'MMM') as Month

Sample script:

numbers:

LOAD * INLINE [

    MonthNumber

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

];

Dates:

load * , Date(Date#(MonthNumber,'M'),'MMM') as Month

Resident numbers;

drop table numbers;

preminqlik
Valued Contributor II

Re: Convert months (numeric) into text

Load *,

text(Date(Date#(fieldname,'MM'),'MMM'))               as               MonthName

from path;

mukesh24
Contributor III

Re: Convert months (numeric) into text

hi,

Simply load inline table in data model or join this table

DIS_MONTH:

LOAD * INLINE [

MONTH1, DISPLAY_MTN

1, Jan

2, Feb

3, Mar

4, Apr

5, May

6, Jun

7, Jul

8, Aug

9, Sep

10, oct

11, Nov

12, Dec

];

Not applicable

Re: Convert months (numeric) into text

Awesome! Thank you!