Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Variable / set analysis

Hi, I need some help to understand something with my variable and how it works.

I have two variables one to set the week and one to to set month.

The variables are defined in the script and looks like this.

let vTodayWeek = week(Today());

let vTodayMonth = Month(Today());

In the Variable Overview i get 33 and aug  as my week and month. So it seems to work fine.

Then here comes the challange.

I then want to create a new variable to display data for the current week and month and in some cases for the past week and past month.

For the week I have done like this and it works like I want it to, I can now just adjust the 0 to a 1 and get the past week :

sum({$<År = {$(=max(År))},Uke={$(=vTodayWeek-$1)},Team={'$2'}>}SCORE_SP1)

/

sum({$<År = {$(=max(År))},Uke={$(=vTodayWeek-$1)},Team={'$2'}>}Teller)/100

and my expression looks like this: =num($(vExprKTIValueTeamWeek1(0,REK TEAM)),'#,##0.0%')  (current week)

num($(vExprKTIValueTeamWeek1(1,REK TEAM)),'#,##0.0%')  (past week)

***For month on the other hand, I can't make it work,****

sum({$<År = {$(=max(År))},Uke={$(=vTodayMonth-$1)},Team={'$2'}>}SCORE_SP1)

/

sum({$<År = {$(=max(År))},Uke={$(=vTodayMonth-$1)},Team={'$2'}>}Teller)/100

and my expressions looks like this: =num($(vExprKTIValueTeamMonth(0,REK TEAM)),'#,##0.0%') (should be current month)

=num($(vExprKTIValueTeamMonth(1,REK TEAM)),'#,##0.0%') (should be past month)

What am I doing wrong with the month? And what must I do to correct it?

Tags (3)
1 Solution

Accepted Solutions
Not applicable

Re: Variable / set analysis

Hi, I have found the solution.

In the script I still keep, let vTodayMonth = month(today());

and in Variable Overview i use this expression

sum({$<År = {$(=max(År))}, Måned = {"$(=month(makedate(1,vTodayMonth - $1)))"}, Team = {'$2'}>}SCORE_SP1)

/

sum({$<År = {$(=max(År))}, Måned = {"$(=month(makedate(1,vTodayMonth - $1)))"}, Team = {'$2'}>}Teller)/100

In the graph i can now use $(vExprKTIValueTeamMonth(0,BEDRIFT 2))  to set the value for this month.

And  $(vExprKTIValueTeamMonth(1,BEDRIFT 2)) for past month.

6 Replies

Re: Variable / set analysis

MVP
MVP

Re: Variable / set analysis

$1 - is not really past week. It actually represents the earlier selection. To get past week , you should probably use -  $(=vTodayWeek-1)   // without dollar sign

Not applicable

Re: Variable / set analysis

The $1 is there to enable me to set the - parameter in the expression.

Example, Expression in variable overview:

sum({$<År={$(=max(År)-$1)},Segment={'$2'}>}[TO Answered Calls Within SL]*SlFlag)

/

sum({$<År={$(=max(År)-$1)},Segment={'$2'}>}[TO Answered Calls])

Expression in the chart:

$(vExprSLSegmentLight(0,B2B))   = 2014

$(vExprSLSegmentLight(1,B2B))  = 2013

You see?

PS: År = Year in Norwegian.

MVP
MVP

Re: Variable / set analysis

Would be an interesting one. Could you post your sample qvw?

Not applicable

Re: Variable / set analysis

here is an example:

Link removed.

had to remove some stuff from the load.

Not applicable

Re: Variable / set analysis

Hi, I have found the solution.

In the script I still keep, let vTodayMonth = month(today());

and in Variable Overview i use this expression

sum({$<År = {$(=max(År))}, Måned = {"$(=month(makedate(1,vTodayMonth - $1)))"}, Team = {'$2'}>}SCORE_SP1)

/

sum({$<År = {$(=max(År))}, Måned = {"$(=month(makedate(1,vTodayMonth - $1)))"}, Team = {'$2'}>}Teller)/100

In the graph i can now use $(vExprKTIValueTeamMonth(0,BEDRIFT 2))  to set the value for this month.

And  $(vExprKTIValueTeamMonth(1,BEDRIFT 2)) for past month.

Community Browser