Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
shanky1907
Creator II
Creator II

Month name to Month number

Hello All,

I have an issue as i want to create a variable with month & year in a format as 'YYYYMM'.

The Month is taken from the getfieldselection and Year as well.

So whatever Month and Year is selected from the Calendar, it should from a variable.

(Both Month and Year are Seperate Listbox).

Please help if you have any idea.

Thanks in advance.

Shashank

10 Replies
kiranmanoharrode
Creator III
Creator III


Create Variable

vYearMonth = Max(Year)&Max(MonthNum)

Regards,
Kiran

shanky1907
Creator II
Creator II
Author

But it will be give me current month as i guess.

But i want to make a variable from the selections made on Month & Year filters.

kiranmanoharrode
Creator III
Creator III


If you select Month and Year, It will change as per your selections.

Regads,

Kiran

shanky1907
Creator II
Creator II
Author

Ok...i got that..What if i want to concatenate both the filed as YYYYMM.

kiranmanoharrode
Creator III
Creator III

then you have to use Concatenated field

=Max(YearMonthNum)

Not applicable

Declare a variable whose expression will evaluate at run time

SET vMyVariable = '=GetFieldSelections(year) & GetFieldSelections(month)';

then you can refer to this in the document by $(vMyVariable) and it will calculate the expression accordingly,

for instance in a textbox =$(vMyVariable) will display the YearMonth selected, moreover you can add a selections count in order to display 0 or whatever you want. notice how important is the = equal sign after the first '.

see attached doc.

shanky1907
Creator II
Creator II
Author

sorry...i didnt get it. Can you please explain?

Let me give you my scenario once again.

I have a Month & a Year filter. I want to make a variable with the selections made in the filters.

This variable should be in Date Format as YYYYMM as i have to compare it another fields in the Chart expressions.

MarcoWedel

can you provide an example of the comparison you have to implement as there might be other possibilities than creating a variable to do so?

Not applicable

Here is an example of showing monthnames and get the month (associated) num and make the date according to selection: so, define the variable as 'MakeDate(only(year),only(month))' either thru document or script load as follows: You can also format later on using Date($(vMyVariable),'heregoesyourformat') in case needed.

LOAD * INLINE [

month, monthName

    1, Jan

    2, Feb

    3, Mar

    4, Apr

     ];

   

    LOAD * Inline [

    year

     2010

     2011

     2012

     2013

     2014];

    

    

     SET vMyVariable = 'MakeDate(only(year),only(month))';

sc_147907.png