Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Combing two number fields into a text field.

I need to combine two number fields together.  I have two fields.  One is Year and the other is Month.

During the load, I want to create a new field with these two fields.

    

Year = 2014 Month = 08

    

The new field will have a new value something like 2014-08

    

Year &”-“& Month  Does not work.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

are you using qlik syntax in the qlik side of the script or in the sql side?

// start of qlik side

LOAD

     .....,

     .....

;

// end of qlik side

// start of sql side

SQL SELECT

     ....

from

     ....

;

View solution in original post

16 Replies
phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

Try single quotes...

Year &'-'& Month as YEAR_MONTH

Not applicable
Author

Thanks for the reply,

My bad, typo I did have single qoutes.

The result value is 0

phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

that is wired... it should work. Here all you are doing is concatenating two fields with a separator.

Year &'-'& Month as YEAR_MONTH


Can you check the number format of this dimension in Document properties -- > Number tab

Mark as "Mixed" .

If that doesn't resolve post a sample QVW

jagan
Luminary Alumni
Luminary Alumni

Hi Tom,

Try like this


LOAD

*,

Text(Year & '-' & Month) AS YearMonth

FROM DataSource;


Now use this new field as dimension wherever you required.


Regards,

Jagan.

ecolomer
Master II
Master II

Try this:

Year &'-'& (num(Month, '00')) as Year_Month


or use the function:

MonthName(Date)    as xMonthYear,


Not applicable
Author

How about

=Year & '-' & Month

Not applicable
Author

I tried this Text(Year & '-' & Month) AS YearMonth

well a verision of it.  Text(Year) & '-'& Text(Month) as YearMonthLink

It came up with a SQL error on load.

MarcoWedel

In order to get a real date field, try this expression

Date(MakeDate(Year, Month, 1), 'YYYY-MM') as MonthName

This way you can also use this field with date functions and in calculations like any other date field.

hope this helps

regards

Marco

maxgro
MVP
MVP

are you using qlik syntax in the qlik side of the script or in the sql side?

// start of qlik side

LOAD

     .....,

     .....

;

// end of qlik side

// start of sql side

SQL SELECT

     ....

from

     ....

;