Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variables' definition

Hi all,

Do anyone know how to use the result of a SQL sentence as the variable's value?

Thanks and best regards,

CoCo

1 Solution

Accepted Solutions
Sokkorn
Master
Master

Hi CoCo,

For this one, I would suggest you load all data from Account table. Like this

[Age]:

SQL Select [Account ID],[Account Name], [Age] From Account;

Create new variable in "Variable Overview" by click Add:

     1. Variable name: vAge2635

     2. Definition: Count({$<[Age]={'26-35'}>} [Account ID])

Regards,

Sokkorn

View solution in original post

17 Replies
Sokkorn
Master
Master

Hi CoCo,

What is your SQL sentence?

Regards,

Sokkorn

Sokkorn
Master
Master

Or Something like this

LET Query = 'SELECT * FROM TableName';

[TableName]:

LOAD *;

SQL $(Query);

Not applicable
Author

CoCo,

1) Put the result into a temp table

2) use the peek function to store the result into a local variable

let MyVar = peek('FieldName', Integer Number, 'Table name')

The number starts at 0 (1st line) and ends at NoOfRows('Table')-1

Fabrice

Not applicable
Author

Hi Scokkorn,

In the qlikview, is the SQL grammar same with standard SQL sentences?

Not applicable
Author

Hi Fabrice,

Sokkorn
Master
Master

Yes, CoCo

SQL Select Field1, Field2 From TableName Where Field1='Value';

Regards,

Sokkorn

Not applicable
Author

Hi Sokkorn,

Actually, I want to creat the variable, using the result of a SQL sentence, in the "Variable Overiew" window.

So how should I do ? Could you please provide a sample for me?

Thanks too much.

Sokkorn
Master
Master

Hi CoCo,

Can you prepare your SQL statement with result set? And manipulate your variable for output?

Regards,

Sokkorn

Not applicable
Author

Oh, great!

But when I use the same sentence in the "Variable Overiew" window, it occurs the grammar errors.

I don't know why!

FYI:

variable.PNG.png