Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
m4u
Partner - Creator II
Partner - Creator II

Convert month number to a string

Hello

I want to display a pivoted report by month only, without the year part.

Assuming I have a transactions table with customer, date, sum fields - how can I do that? I want the columns on the top to show Jan,Feb,Mar and so on and not 1,2,3.

I know how to solve it on the sql level by doing

LEFT(DATENAME(MM,



H.DocDate),3)

but I am looking for some cleaner way of extracting the month name (without year, so MonthName is not good) out of the month number ( I have it anyway) or the full date

1 Solution

Accepted Solutions
msteedle
Partner - Creator
Partner - Creator

Use a preceding load and the QlikView month() function with your date field, e.g.


Calendar:
LOAD TransactionDate,
month(TransactionDate) as Month;
SQL SELECT TransactionDate
FROM SQLCalendar;


View solution in original post

6 Replies
Not applicable

you can do

Month(date) as xMonth;

in the load statement, and use xMonth Field

m4u
Partner - Creator II
Partner - Creator II
Author

I am loading from SQL Server so it gives me the month number..

Not applicable

yes

Month(month_no)

will convert it to Jan, Feb, ......

Not applicable

Hello,

Maybe you can try something like this:

=



Month(MakeDate(2009, monthField))

The "2009" is just so the MakeDate can work.

Steve

msteedle
Partner - Creator
Partner - Creator

Use a preceding load and the QlikView month() function with your date field, e.g.


Calendar:
LOAD TransactionDate,
month(TransactionDate) as Month;
SQL SELECT TransactionDate
FROM SQLCalendar;


Miguel_Angel_Baeyens


M4U wrote:
I am loading from SQL Server so it gives me the month number.. <div></div>


Somethink like

LOAD ... SubField(MonthNames, ';', DateField) AS MonthStr ...
should work, having that MonthName is an environment variable you are already loading in your main tab of your load script. Hope this helps.