Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Anonymous
Not applicable
Author

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.

View solution in original post

13 Replies
Not applicable
Author

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

Anonymous
Not applicable
Author

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

Not applicable
Author

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?

Anonymous
Not applicable
Author

can you attach sample file in which you tried that?

nagaiank
Specialist III
Specialist III

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
Author

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

Not applicable
Author

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)
Anonymous
Not applicable
Author

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
Author

so how do I define that

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