Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
krishna20
Specialist II
Specialist II

Months full names to short Names

Hi Friends,

i'm having the Month_FullName as a field. How can i get short names from this filed.

for e.g; January, February, March...........   to Jan , Feb, Mar, Apr.......

Please suggest how to do it.

Regards

Krishna

1 Solution

Accepted Solutions
MarcoWedel

Hi,

the reason for the behaviour you experienced is that you already loaded your month_fullnames as a date field formatted as month fullnames. So the proposed solutions using the Date# function didn't find a string to interpret as a date (that's what the #-functions do).

On the other hand this means, that your front end expression

=Month(Date(Month_FullNames,'MMM'))

can be abbreviated to

=Month(Month_FullNames)

as the formatting date() function is useless in this case, it does not change the underlying numerical value of your Month_FullNames field (Ret_Month).


Using this expression

Date(Date#(SubField('$(MonthNames)',';',MONTH),'MMM'),'MMMM') as Ret_Month

to create your Ret_Month field in the script leads to somewhat weird underlying numerical values:

QlikCommunity_Thread_139592_Pic1.JPG.jpg

because you are trying to create a complete date value from only a month field (the year information is missing) and then just formatting it to show month fullnames.

I therefore stick to my proposed solution

Dual(Date(Date#(MONTH,'MM'),'MMMM'), MONTH) as Ret_Month

which creates these underlying values:

QlikCommunity_Thread_139592_Pic2.JPG.jpg

like one would expect from a real month field.

If you wanted to create the month shortname field in the script, then one solution could be:

Month(Date#(MONTH,'MM')) as Ret_Month_short

hope this helps

regards

Marco

View solution in original post

22 Replies
markodonovan
Specialist
Specialist

Hi Krishna20,

Would this work in all months :

left('January',3)

Mark

www.techstuffy.com

krishna20
Specialist II
Specialist II
Author

Hi Mark ,

Thank you for your immediate reply. I want to show all field names in list box.

Regards

Krishna

its_anandrjs

Use mapping table or otherwise load another table like

Fact:

load * inline

[

FullNameMonths

January

February

March

April

May

June

July

August

September

October

November

December

];


MonthTable:

Load * inline[

FullNameMonths, SortMOnthName

January, Jan

February, Feb

March, Mar

April, Apr

May, May

June, Jun

July, Jul

August, Aug

September, Sep

October, Oct

November, Nov

December, Dec

];

And in place of the FullNameMonths use SortMOnthName

Regards,

Anand

Not applicable

Hi,

Left(Month,3)

or else

Month(Month_fullname,'MMM')

Or else create a inline table with month field

Load * inline[

Month_fullName, Monthname

January, jan

];

MarcoWedel

e.g.

Month(Date#('September','MMMM'))

returns 'Sep' with an underlying numerical value of 9

hope this helps

regards

Marco

its_anandrjs

Even you can map another table like

MapTab:

Mapping LOAD * INLINE [

    FullNameMonths, SortMonthName

    January, Jan

    February, Feb

    March, Mar

    April, Apr

    May, May

    June, Jun

    July, Jul

    August, Aug

    September, Sep

    October, Oct

    November, Nov

    December, Dec ];

LOAD  ApplyMap('MapTab',FullNameMonths) as SortMonName,FullNameMonths;

LOAD * INLINE [

    FullNameMonths

    January

    February

    March

    April

    May

    June

    July

    August

    September

    October

    November

    December ];

And in list bx use only SortMonName  field

Regards,

Anand

MarcoWedel

For localization issues you can adjust the long month names with this variable:

SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';

hope this helps also

regards

Marco

amit_saini
Master III
Master III

Krishna,

Like this , see the attachment.

Thanks,

AS

MarcoWedel

QlikCommunity_Thread_139592_Pic1_.JPG.jpg