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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
madhubabum
Creator
Creator

How to create a Table

Hi All

I have the following scenario,......

YearRange:

Load Max(Year) as MaxYear, Min(Year) as MinYear resident Table1;

Let vMaxYear= Peek('MaxYear',0,'YearRange');

Let vMinYear= Peek('MinYear',0,'YearRange');

Set vRangeMax=$(vMaxYear);

Set vRangeMin=$(vMinYear);

Drop Table YearRange;

Do

Load

$(vRangeMax) as Year

Resident Table1

where Year=$(vRangeMax)-1;

Set vRangeMax= Num($(vRangeMax))-1;

LOOP while $(vRangeMax) >$(vRangeMin);

Store Table1 into 'D:\Table1.qvd';

Note : " $(vRangeMax) "   is showing an error......

How we can load table...

Thanks

Madhu

10 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

The problem is due to the $ expansion in the Set command returning a null. Although a Set command expression is not evaluated, the $ expansion happens before the Set statement. What you need to do is to defer the $ expansions. You can do this;

Let vRangeMax = '$' & '(vMaxYear)';


This prevents the $ expansion from happening in the script.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

I often do this instead:

Set vRangeMax = #(vMaxYear);

Let vRangeMax = Replace(vRangeMax, '#', '$');


This is useful for complex expressions which are awkward with the single step process - although for simple ones i would use the first suggestion.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
madhubabum
Creator
Creator
Author

Hi Jonathan

Thanks Your reply...

Where i want to use & Where i want to declare variables.

Thanks

Madhu

madhubabum
Creator
Creator
Author

Hi Jonathan

-> Once we debug the script ...

Output :

Syntax error, missing/misplaced FROM:

Load

  as Year,..........

jonathandienst
Partner - Champion III
Partner - Champion III

madhu babu wrote:

Where i want to use & Where i want to declare variables.

I don't understand the question

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

madhu babu wrote:

-> Once we debug the script ...

Output :

Syntax error, missing/misplaced FROM:

Load

  as Year,..........

You are probably missing a semi-colon or comma somewhere

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
madhubabum
Creator
Creator
Author

Hi Jonathan

After Load

"$(vRangeMax)"  does not recognize

sasiparupudi1
Master III
Master III

change Set vRangeMax= Num($(vRangeMax))-1;

to let vRangeMax= Num($(vRangeMax))-1;

jonathandienst
Partner - Champion III
Partner - Champion III

Something is wrong with your (updated) script, but without seeing it, I cannot help you.

madhu babu wrote:

After Load

"$(vRangeMax)"  does not recognize

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein