# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Not applicable

## How can I define these variables in the script?

I would like to make a #Include script that returns these variabls:

• vCurQtr = Text(Year(Today())+Max(CurYr)) & '-' & concat(CurrQtr)
• cCurYrYr = Text(Year(Today())+Max(CurYr))
• vQOQQtr =  Text(Year(Today())+Max(PriorYr)) & '-' & concat(PriorQtr)
• vPriorPriorQtr = Text(Year(Today())+Max(PriorPriorYr)) & '-' & concat(PriorPriorQrt)
• vPriorPriorPriorQtr = Text(Year(Today())+Max(PriorPriorPriorYr)) & '-' & concat(PriorPriorPriorQrt)
• vYOYQtr = Text(Year(Today())+Max(CurYr)-1) & '-' & concat(CurrQtr)
• vCurQOQYOY_Qtr = '(' & vCurQtr & ' | ' & vQOQQtr & ')'
• vRollingQtrs_4 = '(' & vCurQtr & ' | ' & vQOQQtr & ' | ' & vPriorPriorQtr & ' | ' & vPriorPriorPriorQtr & ')'
• vCurYr = '(' & vCurYrYr & '-Q1 | ' & vCurYrYr & '-Q2 | ' & vCurYrYr & '-Q3 | ' & vCurYrYr & '-Q4)'

Right now I have had to define these in the Variable Overview so I would have to define these on every document that uses these variables.  Is there a way to make this a script that loads my table (see attached QlikView and XLS) and then creates these variables and then drops the table?

Thank you very much!

1 Solution

Accepted Solutions
Contributor

## Re: How can I define these variables in the script?

Quartername is a inbuilt QlikView function. If you mandatorily have to have Q1 then you have to use mapping or you have to hardcode string.

13 Replies
Not applicable

## Re: How can I define these variables in the script?

Why did this get marked as "Assumed Answered"?  I just posted it.

Contributor

## Re: How can I define these variables in the script?

Hi, Try using "let" & "Set" function in Edit Script box while loading the data.

Not applicable

## Re: How can I define these variables in the script?

I tried that but get line errors on all of the variables.  Not really sure what I am doing wrong.  It appears to have a problem with Peek and Concat both in the script... so how do I get the value from the table loaded into the variable?

Contributor

## Re: How can I define these variables in the script?

can you attach sample file in which you tried that?

Valued Contributor III

## Re: How can I define these variables in the script?

I think you need to define the variables to have the text used. For example,

vCurQtr = 'Text(Year(Today())+Max(CurYr))' & Chr(38) & '-' & Chr(38) & 'Concat(currQtr)'

Not applicable

## Re: How can I define these variables in the script?

I added DateAutomation2.qvw to the discussion... not sure how to add it here.

Not applicable

## Re: How can I define these variables in the script?

My goal is to set the variables, not leave them dynamic... so were it to run today, it would say:

• vCurQtr = 2013-Q1
• cCurYrYr = 2013
• vQOQQtr = 2012-Q4
• vPriorPriorQtr = 2012-Q3
• vPriorPriorPriorQtr = 2012-Q2
• vYOYQtr = 2012-Q1
• vCurQOQYOY_Qtr = (2013-Q1 | 2012-Q4)
• vRollingQtrs_4 = (2013-Q1 | 2012-Q4 | 2012-Q3 | 2012-Q2)
• vCurYr = (2013-Q1 | 2013-Q2 | 2013-Q3 | 2013-Q4)
Contributor

## Re: How can I define these variables in the script?

There are different ways of doing it. See if this helps you

let vtoday=today();

let vCurrQtr=QuarterName (today());

let vCurrYr=year(today());

let vPriorQ4=QuarterName(today()-90);

let vPriorQ3=QuarterName(today()-180);

let vPriorQ2=QuarterName(today()-270);

let vPriorQ1=QuarterName(today()-365);

let vCurQOQYOY_Qtr =QuarterName (today()) &'|'&QuarterName(today()-90);

Not applicable

## Re: How can I define these variables in the script?

so how do I define that

"QuarterName(today())" returns 2013-Q1?

Community Browser