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

Add year to month field

Hi All,

i have one data file, which contains Project Number, Project Name, November, December, January as fields. Here November and December belongs to 2013 year and January belongs to 2014. In future they may add data for February, March...

My requirement is i have to change November as Nov, December as Dec, January as Jan...... and i want add year as Nov-13, Dec-13, Jan-14, Feb-14...... But i don't have Year field in my datasheet

I tried with "left(Month,3)&'-'&right(if(left(Month,3) = 'Dec' or 'Nov' or left(Month,3) = 'Nov',  Year(Today()), if(left(Month,3) = 'Jan',Year(Today())+1)),2) as Month". But it is not correct way because it works for 3 months.

Please anybody can take a look into this requirement and give me suggestion.

i attached sample QVW and Data file also

Thanks,

M V

12 Replies
Not applicable
Author

Hi Guys,

Any Suggestions ?

Thanks,

M V 

Not applicable
Author

hi,

  I don't think so this can be done dynamically. but one thing tell me why you are not changing your column name in excel or at the time of load. Because i think you can only change field name dynamically using variables.

Assign any value in a variable and give  alias name as like in load script:

   

     Let varDate = 'Nov-13';

          Load             

                FieldName  AS  $(varDate)]  

          Resident tableName;

Regards,

Ashutosh

Not applicable
Author


Hi Reddy,

Not sure how sustainable the model could be without an Year field but if your data set will be limited from Nov -13 to Oct - 14, then I think you could probably have an inline table and put this info.

Table:

LOAD * INLINE [
    Month, MonthName
    November, Nov - 13
    December, Dec - 13
    January,  Jan - 13
    ..................
    ..................
    October, Oct - 13
]
;

But if you have further data,  wonder how would you identify between Dec - 2013 and Dec - 2014

Regards,

Sree