Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
rsdhavle
Creator II
Creator II

Getting monthname from composite key

I have one composite key of year and month having values like 201112, 201111,201203..

I want to calculate monthname from this values. How can i get that?

1 Solution

Accepted Solutions
Not applicable

Hi,

Check this code,

LOAD * INLINE [
       F1
    201304
    201405
    201212
]
;

Load Date#(month(date#(right(F1,2),'MM'))&'-'&Year(date#(left(F1,4),'YYYY')),'MMM-YYYY') as month
Resident
test;

it gives me data like

Dec-2012

Apr-2013

May-2014

If still facing issues, attach some sample.

HTH

-Shruti

View solution in original post

10 Replies
puttemans
Specialist
Specialist

'right(composite key,2) as Month' will give you the last 2 digits of your key, and recode it as month.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Use

   Date(Date#(CompositeKey&'01', 'YYYYMMDD'), 'MMMM')

for the full month name.

Peter

Edit: Sorry, correct now

Not applicable

Hi,

You can try this,

Date#(month(date#(right('201203',2),'MM'))&'-'&Year(date#(left('201203',4),'YYYY')),'MMM-YYYY')

HTH

-Shruti

ashwanin
Specialist
Specialist

Month(Fiedl) as Month

ashwanin
Specialist
Specialist

and if you want to display the Year also then

Month(Field)&'-'&lEFT(Field,4) as DATE_YEAR

rsdhavle
Creator II
Creator II
Author

Shruti,

When i pass yearmonth that is my fieldname instead of 201203 this expression is not working

Not applicable

Hi,

When using field no qoutes required.

As per my knowledge this works on field too.

I will check on dummy field and get back.

-shruti

puttemans
Specialist
Specialist

If you put = right(yearmonth,2) in your dimension of the chart (first add yearmonth, and then click 'edit', and you enter the expression, then the chart will show you the months.

Not applicable

Hi,

Check this code,

LOAD * INLINE [
       F1
    201304
    201405
    201212
]
;

Load Date#(month(date#(right(F1,2),'MM'))&'-'&Year(date#(left(F1,4),'YYYY')),'MMM-YYYY') as month
Resident
test;

it gives me data like

Dec-2012

Apr-2013

May-2014

If still facing issues, attach some sample.

HTH

-Shruti