Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Convert Month Number to Month Name in Straight Table

I have a text file as a source which gives me product sales for every month. Now some product were not sold on a particular month, so it is not specified in that source file.

Now i want to display it in a straight table having those month(not existing in source file) with sales value 0. I used ValueLoop() in dimension as well as expression  to calculate.

User want Month to be displayed in 'Jan', 'Feb' format  and i am not able to convert valueloop() output in 'MMM' format. Please Help.

Example

Source format

     

Product CategoryProduct NameMonthYearSales
ClothingJeans12016100
FurnitureChair22016500
FurnitureTable22016150
ClothingTshirt52016452
ClothingShirt42016550
FurnitureTable42016465

Output in similar format

     

Product CategoryProduct NameMonthYearSales
ClothingJeansJAN2016100
ClothingTshirtMAY2016452
ClothingShirtAPR2016550
ClothingJeansFEB20160
ClothingJeansMAR20160
ClothingJeansAPR20160
ClothingJeansMAY20160
ClothingJeansJUN20160
ClothingJeansJUL20160
ClothingJeansAUG20160
ClothingJeansSEP20160
ClothingJeansOCT20160
ClothingJeansNOV20160
ClothingJeansDEC20160
ClothingTshirtFEB20160
ClothingTshirtMAR20160
ClothingTshirtAPR20160
ClothingTshirtMAY20160
ClothingTshirtJUN20160
ClothingTshirtJUL20160
ClothingTshirtAUG20160
ClothingTshirtSEP20160
ClothingTshirtOCT20160
ClothingTshirtNOV20160
ClothingTshirtDEC20160
ClothingShirtFEB20160
ClothingShirtMAR20160
ClothingShirtAPR20160
ClothingShirtMAY20160
ClothingShirtJUN20160
ClothingShirtJUL20160
ClothingShirtAUG20160
ClothingShirtSEP20160
ClothingShirtOCT20160
ClothingShirtNOV20160
ClothingShirtDEC20160
FurnitureChairFEB2016500
FurnitureTableFEB2016150
FurnitureTableAPR2016465
9 Replies
maxgro
MVP
MVP

maybe

Date(MakeDate(2000, ValueLoop(1,12)), 'MMM')

sunny_talwar

Another way

Month(Date#(ValueLoop(1, 12), 'M'))

Not applicable
Author

It's not working. I am getting blank as output

Not applicable
Author

It would welcome if there is another way of doing things. I mean except valueloop function, something in script to achieve this

rupamjyotidas
Specialist
Specialist

Maybe in Script: You can use this script to change the month to MMM

Main:

LOAD [Product Category],

     [Product Name],

     Month,

     Year,

     Sales,

     [Product Category]&[Product Name]&Month as Key

FROM

[https://community.qlik.com/thread/243552]

(html, codepage is 1252, embedded labels, table is @1);

Temp:

Load Distinct

[Product Category],

     [Product Name],

     Year

   

     Resident Main;

     Join(Temp)

     LOAD * INLINE [

     Month

     1

     2

     3

     4

     5

     6

     7

     8

     9

     10

     11

     12

];

NoConcatenate

Tenp1:

Load

*,

0 as Sales

Resident Temp;

Drop Table Temp;

Concatenate(Main)

Load

* ,

1 as Flag

Resident Tenp1 where NOT Exists(Key,[Product Category]&[Product Name]&Month);

Drop table Tenp1;

neelamsaroha157
Specialist II
Specialist II

As suggested by Massiomo, You can tweak your expression as

Date(MakeDate(Year, Month), 'MMM') in the script

MarcoWedel

Hi,

using Sunny's solution in the script would look like:

QlikCommunity_Thread_243552_Pic1.JPG

tabSales:

LOAD [Product Category],

    [Product Name],

    Month(Date#(Month,'M')) as Month,

    Year,

    Sales

FROM [https://community.qlik.com/thread/243552] (html, codepage is 1252, embedded labels, table is @1);

please notice that although looking similar the different suggested ways to create your Month field are not equivalent:

The underlying numerical values of the dual Month fields are the month numbers 1 to 12 when creating like Month(...)  while the value represents a date when creating like Date(... , 'MMM').

Maybe also helpful:

QlikView Date fields

Get the Dates Right

How to use - Master-Calendar and Date-Values

hope this helps

regards

Marco

nagarjuna_kotha
Partner - Specialist II
Partner - Specialist II

try This :

If u want use in Front End  Use this :

=Pick(Match(Month,1,2,3,4,5,6,7,8,9,10,11,12),'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')

If u want use in BackEnd  Use this :

Pick(Match(Month,1,2,3,4,5,6,7,8,9,10,11,12),'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec') as MonthName



Hope this Helps


-Nagarjun

Anonymous
Not applicable
Author

Hi,

You can use applymap also in script like following

MonthMap:

Load * Inline [

Month, MonthName

1,Jan

2,Feb

3,Mar

4,Apr

5,May

6,Jun

7,Jul

8,Aug

9,Sep

10,Oct

11,Nov

12,Dec

];

tabSales: 

LOAD [Product Category], 

    [Product Name], 

Applymap('MonthMap',Month) as MonthName,

   Year, 

    Sales 

From......

Thanks,