Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

Real Long Month Names, sorted by number of month, not alphabetical order

Hi all,

I'a aware that this is a well documented topic. However, I haven't found the answer to the solution I need for a Master Calendar. I have set the formats as follows:

SET MonthNames='Jan;Feb;Mrz;Apr;Mai;Jun;Jul;Aug;Sep;Okt;Nov;Dez';

SET DayNames='Mo;Di;Mi;Do;Fr;Sa;So';

SET LongMonthNames='Januar;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember';

SET LongDayNames='Montag;Dienstag;Mittwoch;Donnerstag;Freitag;Samstag;Sonntag';

LET vTempDate = Today();

Then I generate a temporal table with daily dates, based on the variable vTempDate. Then I reload this temporal table and calculate all kind of "handles" to be used later with the GUI. Part of the script is as follows

...

WeekDay (vTempDate) as Wochentag,

date(vTempDate,'WWWW') as WochentagLang,

Week(vTempDate) as Woche,

num(Month(vTempDate)) as Monat,

month(date(vTempDate, 'MMMM')) as MonatLong,

month(vTempDate) as Monat_Name,

....

Now, the handle I'm still missing is MonatLong. That should read Januar, Februar, März, etc. with the underlying number of the month for sorting in the correct manner. However, all I have achieved so far, is that MonatLong comes out as Jan, Feb, Mrz,....

I also tried to generate  long month names using

if(num(Month(vTempDate)) = 1,'Januar',if(num(Month(vTempDate))=2,'Februar',if(num(Month(vTempDate))=3,'März',if(...

or

Date#(date(vTempDate, 'MMMM')) as MonatLong,

But then the correct sorting order (according to number of Month) is lost and MonatLong just sorts in an alphabetical order.

Anyone any ideas?  Thanx and kind regards

1 Solution

Accepted Solutions
MVP
MVP

Re: Real Long Month Names, sorted by number of month, not alphabetical order

Try

Dual(date(vTempDate, 'MMMM'),Month(vTempDate) ) as MonatLong,

8 Replies
MVP
MVP

Re: Real Long Month Names, sorted by number of month, not alphabetical order

Try

Dual(date(vTempDate, 'MMMM'),Month(vTempDate) ) as MonatLong,

Re: Real Long Month Names, sorted by number of month, not alphabetical order

Try this for MonthLong and it should sort without any other modification by sorting it by numeric ascending:

Date(MonthStart(vTempDate), 'MMMM') as MonatLong,

Re: Real Long Month Names, sorted by number of month, not alphabetical order

If I understand your requirement, you need long month name..

If that is write then all you need to do is change the value of variable Monthname as below.

SET MonthNames='Januar;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember';


Same with Day Name.


and then use normal function month(Date) to get the long month name.


Regards,

Kaushik Solanki

MVP
MVP

Re: Real Long Month Names, sorted by number of month, not alphabetical order

Hi Sunny,

I think that will create multiple distinct values for a given Month over years.

Re: Real Long Month Names, sorted by number of month, not alphabetical order

Hmmm, that is a very good point

Re: Real Long Month Names, sorted by number of month, not alphabetical order

In the following script line:

:

month(date(vTempDate, 'MMMM')) as MonatLong,

:

remove the Month() function call. Month will reset the format back to short month names. Date on its own will do the trick, like:

:

date(vTempDate, 'MMMM') as MonatLong,

:


Of course, since the underlying value will still be a date, your long month name will appear for every different date value (and every month name will appear many times in a list box). If you want to avoid that, use MonthStart to pre-format the date value, as Sunny suggested.


Peter


Not applicable

Re: Real Long Month Names, sorted by number of month, not alphabetical order

Hi Sunny Ti

You're solution worked too! :-)

Re: Real Long Month Names, sorted by number of month, not alphabetical order

Great

Community Browser