Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Store Variable value in QVD

Dear all,

I want to store a variable in a QVD file. Therefore I use the following script:

TableKPI:

Load

    '$(Load_Date)' as Load_Date,

     '$(TCAssessed)' as TCAssessed,

     '$(TCPassed)' as TCPassed

     AutoGenerate 1;

Concatenate(TableKPI)

Load * from TableKPI.qvd (qvd);

Store TableKPI into TableKPI.qvd (qvd) ;

I have defined the variables TCAssessed and TCPassed in my Qlikview file. They are both expressions.

TCAssessed=count(Value1)

TCPassed= sum(if(Value1= '1',1,0))

The problem is that Qlikview doesn't store the value into the qvd but the formula.

How can I store the numeric value instead of the formula?

Thanks in advance!

Kind regards,

Jens

1 Solution

Accepted Solutions
jagannalla
Partner - Specialist III
Partner - Specialist III

Hello,

You can't do like that. See in your variable you are writing the expression so when you start loading the script the variable will not hold any value, b'coz the variable hold the value once the load is completed. The expression in the variable will not written any value while application is loading.

If you want to test the application just give the value of the variable manually i.e TCAssessed=1 and load the application it will work.

-If you want to work it please create dummy variables and try to store static values which are written by the expression, then use those variables in the script.

Otherwise,

Temp:

Load TCAssessed,TCPassed from TableKPI.qvd (qvd); 

LET vTCAssessed= FieldValueCount('TCAssessed');

Drop Table Temp;

TableKPI:

Load

         '$(TCAssessed)' as TCAssessed,

AutoGenerate 1;

Concatenate(TableKPI)

Load * from TableKPI.qvd (qvd);

Store TableKPI into TableKPI.qvd (qvd) ;

Hope it helps you

cheers!

jagan

View solution in original post

7 Replies
jvitantonio
Luminary Alumni
Luminary Alumni

Use LET infront of the variable

LET TCAssessed=count(Value1)

Not applicable
Author

Thanks for your quick reply but could you indicate where you put the LET?

At the moment I define this variable in my QV dashboard (so from Settings> Variable Overview).

I don't see where I should put the LET.

Can I define the variable directly in my Load script? Before I define my table?

jvitantonio
Luminary Alumni
Luminary Alumni

Correct. You can define it in your script.

Not applicable
Author

When I define my attributes in my load script I get several errors when loading the data.

This is my script:

LET TCAssessed=count([# of possible tc]);

LET Load_date=Today();

Let TCPassed= sum(if([# of possible tc]='BAS',1,0));

TableKPI:

Load

     $(Load_Date) as Load_Date,

     $(TCAssessed) as TCAssessed,

     $(TCPassed) as TCPassed

     AutoGenerate 1;

Concatenate(TableKPI)

The error message reads:

Syntax error, missing/misplaced FROM:

TableKPI:

Load

      as Load_Date,

      as TCAssessed,

      as TCPassed

     AutoGenerate 1

TableKPI:

Load

      as Load_Date,

      as TCAssessed,

      as TCPassed

     AutoGenerate 1

Do you have any idea what the problem might be?

Load * from TableKPI.qvd (qvd);

Store TableKPI into TableKPI.qvd (qvd) ;

jagannalla
Partner - Specialist III
Partner - Specialist III

Hello,

You can't do like that. See in your variable you are writing the expression so when you start loading the script the variable will not hold any value, b'coz the variable hold the value once the load is completed. The expression in the variable will not written any value while application is loading.

If you want to test the application just give the value of the variable manually i.e TCAssessed=1 and load the application it will work.

-If you want to work it please create dummy variables and try to store static values which are written by the expression, then use those variables in the script.

Otherwise,

Temp:

Load TCAssessed,TCPassed from TableKPI.qvd (qvd); 

LET vTCAssessed= FieldValueCount('TCAssessed');

Drop Table Temp;

TableKPI:

Load

         '$(TCAssessed)' as TCAssessed,

AutoGenerate 1;

Concatenate(TableKPI)

Load * from TableKPI.qvd (qvd);

Store TableKPI into TableKPI.qvd (qvd) ;

Hope it helps you

cheers!

jagan

Not applicable
Author

Thanks Jagan!

You answer helped a lot and I was able to create a workaround by using a button.

Thanks for the help!

jagannalla
Partner - Specialist III
Partner - Specialist III

Can you please mark as correct answer. It helps others to understand the problem easily.