Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

tan_chungkam
Contributor

Convert Number into Year and Week

Hi Qlikers,

How can I make Qliksense recognize numbers and Year and Week.

I have a column contain below number:

201852 Year 2018 Week 52

Thus when I add 1 week into the number, it should become 201901.

Labels (1)
3 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Re: Convert Number into Year and Week

I usually create a WeekStart field using the WeekStart() function:

WeekStart(MakeWeekDate( Left(MyYearWeekField,4), Right(MyYearWeekField,2))) as MyWeekStartField

Then to format it as the YearWeek number you can use the Dual function:

Dual(MyYearWeekField , WeekStart(MakeWeekDate( Left(MyYearWeekField,4), Right(MyYearWeekField,2)))) as MyWeekStartField

When you add 7 to a value of that field you get the next week since it's a date based field which has a unit of 1 day.

 


talk is cheap, supply exceeds demand
tan_chungkam
Contributor

Re: Convert Number into Year and Week

Hi @Gysbert_Wassenaar,

When i added 7 into the YearWeek,

It should return figure like 43570,43591 and etc.

How to return theses figure to 201901, 201902

MVP & Luminary
MVP & Luminary

Re: Convert Number into Year and Week

It should return figure like 43570,43591 and etc.

Should or does? If it does then YearWeek is already a date field and you can use the Dual function to apply the formatting:

Dual( Year(YearWeek)*100+Week(YearWeek), YearWeek  )


talk is cheap, supply exceeds demand