Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
AndreasMoller
Contributor III
Contributor III

Mapp date column with 2 columns, year and month

Hello,

I want to make a mapping load where i map one datefield, format: YYYY-MM-DD, with 2 fields that represent year and month (number format). 

I have tried a couple of differents things, ex:

First mapping: Year(date(Datefield)) & '#' & Num(Month(date(Datefield)))
mapping too: Yearfield & '#' & Monthfield

Does anyone know a solution to my problem?

 

Labels (1)
1 Solution

Accepted Solutions
AronC
Partner - Creator II
Partner - Creator II

@AndreasMoller 

If you instead of mapping. Just load the two tables. Is there a key that binds them together?

Just load Year(date(Datefield)) & '#' & Num(Month(date(Datefield))) as %YearMonth

And also Yearfield & '#' & Monthfield as %YearMonth

What does it look like then? Please show a screenshots of the vaules in each fields.

Instead of Num if you want numeric value, use floor. Num is great for formatting the text-representation for a number, but I never use it to create a numeric value.

View solution in original post

5 Replies
Bhuvi
Partner - Contributor III
Partner - Contributor III

Can you please share the full script

AndreasMoller
Contributor III
Contributor III
Author

Sure, here it comes:

map_Test:
Mapping load
Yearfield & '#' & Monthfield,
ColumnTest
from $(vPathQvdExtracted)tabell1.qvd (qvd);

applymap('map_Test',  Year(date(Datefield)) & '#' & Num(Month(date(Datefield))),  1)         as  ColumnTest
from $(vPathQvdExtracted)tabell2.qvd (qvd);

AronC
Partner - Creator II
Partner - Creator II

@AndreasMoller 

If you instead of mapping. Just load the two tables. Is there a key that binds them together?

Just load Year(date(Datefield)) & '#' & Num(Month(date(Datefield))) as %YearMonth

And also Yearfield & '#' & Monthfield as %YearMonth

What does it look like then? Please show a screenshots of the vaules in each fields.

Instead of Num if you want numeric value, use floor. Num is great for formatting the text-representation for a number, but I never use it to create a numeric value.

AndreasMoller
Contributor III
Contributor III
Author

Thanks for your answer, i think i solved it with your help!

This script did i use in the solution:
applymap('mapKursKoncernvaluta', floor(Year(date(Datefield))) & '#' & floor(Month(date(Datefield))) , 1)

AronC
Partner - Creator II
Partner - Creator II

@AndreasMoller Glad to hear I could help you out! 😄

Please mark response as solution if it solved your problem.

Cheers!