Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
Partner
Partner

Format the result of WeekName() function

Hello,

 

MonthName()'s return is formatted according to the MonthNames script variable.

Is there a similar way to format WeekName()'s return, as YYYY/WW does not suit me (I'd like something like WW-YYYY)

 

Thank you !

Labels (2)
1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Re: Format the result of WeekName() function

Try this:

dual(num(Week(DateField), '00')&'-'& WeekYear(DateField), WeekName(DateField)) as WeekName

Plees ekskuse my Swenglish and or Norweglish spelling misstakes

View solution in original post

6 Replies
Highlighted
Taoufiq_ZARRA
Valued Contributor

Re: Format the result of WeekName() function

I'll wait for the other feedback as too.
but to my knowledge there is no such formatting.

so transforms into text:

=week('12/01/2013')&'-'&year('12/01/2013')

Capture.JPG


Taoufiq ZARRA
Highlighted
Partner
Partner

Re: Format the result of WeekName() function

Try this:

dual(num(Week(DateField), '00')&'-'& WeekYear(DateField), WeekName(DateField)) as WeekName

Plees ekskuse my Swenglish and or Norweglish spelling misstakes

View solution in original post

Highlighted
Partner
Partner

Re: Format the result of WeekName() function

@Taoufiq_ZARRA  

I reccomend you to use yearweek() not year() when creating week names. Using Year() will give you trouble on certain dates. Consider the example below:

=week('01/01/2017')&'-'&year('01/01/2017')

Will return '52-2017' indicating it is in the end of 2017 which its not. 

 

=week('01/01/2017')&'-'&weekyear('01/01/2017')

Will return '52-2016' which is a more correct name for this date. 

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Highlighted
Taoufiq_ZARRA
Valued Contributor

Re: Format the result of WeekName() function

@Vegar 

Well said, thank you very much.
I'm still learning 😊


Taoufiq ZARRA
Highlighted
Partner
Partner

Re: Format the result of WeekName() function

@Taoufiq_ZARRA 

We all are and the Qlik Community is a really good place to learn.

Thank you for contributing.

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Partner
Partner

Re: Format the result of WeekName() function


@Vegar wrote:

Try this:

dual(num(Week(DateField), '00')&'-'& WeekYear(DateField), WeekName(DateField)) as WeekName


I have that in some places of my scripts, but I noticed that sometimes this is being interpreted by qlik as a substraction, and gives weird results.

I just checked out what 'dual()' is, and this is brilliant. I believe it fixes the problem.

Thank you very much !