Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL Statement in LET Statement

Hi All,

Can I use the SQL Statement in LET statement. For example I want to calculate the minimum date from a table initialize to a variable. So that it can be used in my calender.

For example I want do some thing like the below one to that I can use vDateMin in any of the variable for MinDate in my calender.


LET vDateMin = SQL Select min(d_entry_date) from Tbl_DWR;


3 Replies
shumailh
Creator III
Creator III

As per my knowledge you cant put sql query in a variable at script level but you can do it at the design / development level by defining variable in document.

Regards,
Shumail Hussain

suniljain
Master
Master

Dear Rikab,

Let Statement works like variable declaration and Initialization. So during that time you cant assign value from any backend tool.

Regards,

Sunil Jain.

Not applicable
Author

This can be work for you.

We can get a value from a table, such in that example:

Currrency:
LOAD * INLINE [
"X" , "XValue"
usd , usdValue
eur , eurValue
tl , tlValue
];
SET vCurrency = '=Minstring("XValue")';

So if you store your result on a table, you can use its columns, and take into a variable.
If we customize to your case, You can try this:

MinDate:
SQL Select min(d_entry_date) As mDate from Tbl_DWR;

SET vCurrency = '=Minstring("mDate")';