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

help on adding proper year to month

I have data as follows:

loadingmonthproduction cost
123,48
243,15
383,25
1/1923,43
2/1953,41

 

I need to convert month to text and add year.

Month values (2,4,8) are Feb 2018, April 2018, August 2018 based on loading column (1, 2, 3).

Month values (2, 5) based on loading column (1/19 i 2/19) are respectively Feb 2019 and May 2019.

Could you assist?

 

Labels (1)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

LOAD 
	monthname( makedate(alt(year(date#(loading, 'M/YY')), 2018) , month)) as YearMonth, 
	* 
inline [
loading,month,	production cost
1,		2,		3.48
2,		4,		3.15
3,		8,		3.25
1/19,	2,		3.43
2/19,	5,		3.41];
exit script;

 

This assumes that you will have year for all loadings except when year = 2018, but then you will be able to get the year month as below.

 

image.png

View solution in original post

2 Replies
Vegar
MVP
MVP

LOAD 
	monthname( makedate(alt(year(date#(loading, 'M/YY')), 2018) , month)) as YearMonth, 
	* 
inline [
loading,month,	production cost
1,		2,		3.48
2,		4,		3.15
3,		8,		3.25
1/19,	2,		3.43
2/19,	5,		3.41];
exit script;

 

This assumes that you will have year for all loadings except when year = 2018, but then you will be able to get the year month as below.

 

image.png

Anil_Babu_Samineni

How to identify Which month will under Which year, Any other logic to note?

 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful