Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
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?

1 Solution

Accepted Solutions
Not applicable
Author

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.

View solution in original post

6 Replies
ashfaq_haseeb
Champion III
Champion III

tresesco
MVP
MVP

$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
Author

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.

tresesco
MVP
MVP

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

Not applicable
Author

here is an example:

Link removed.

had to remove some stuff from the load.

Not applicable
Author

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.