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: 
dandaanilreddy
Partner - Creator III
Partner - Creator III

Auto concatenate not working in qlik sense

Hello All,

I'm trying to execute 10 sql queries in qlik sense which have same fields but different data but the output is showing same values for all the tables. Below is my script. 

Table:

Load 

Name,

sql_statement,

Product

from table;

Test:

load 

' ' as Empty,

autogenerate 0;

For I=0 to Noofrows('Table')-1

let vName= peek('Name','$(i)','Table);

let vproduct = peek('Product','$(i)','Table);

let vSQL = peek('sql_statement','$(i)','Table);

let vSQL_Query= replace(replace(peek('sql_statement',0,'Table'),'Product','$(vproduct)'),'DB','$(vDB)');

LIB connect to '$(vConn)';

Concatenate(Test)

load 

*,

'$(vName)' as Table_Name;

SQL $(vSQL_Query);

Next i

drop table Table;

 

 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

I notice this row

let vSQL_Query= replace(replace(peek('sql_statement',0,'Table'),'Product','$(vproduct)'),'DB','$(vDB)');

Your peek are always looking at the same row, row 0. Maybe you need to use the variable i here as you do for the other peek statements.

let vSQL_Query= replace(replace(peek('sql_statement',$(i),'Table'),'Product','$(vproduct)'),'DB','$(vDB)');

I also notice that you loop is done on 'I' and not 'i' as expected in the peek statements. (But I assume that is just another spelling error)

 

View solution in original post

4 Replies
Vegar
MVP
MVP

 

Do you get an error message?

I would guess that you run into trouble on this line:

Concat(Test)

Try changing it to Concatenate (Test) instead.

Concatenate () is the correct function when concatenating data in a load. Concat() is used for aggregating a field inside an application. 

dandaanilreddy
Partner - Creator III
Partner - Creator III
Author

Hi Vegar,

Sorry i have manually written the above script. Yes i used concatenate. The issue i see here is same sql is executing for all the names (Table Name). So the output is showing same results for all these 10 tables. 

 

Thanks

Vegar
MVP
MVP

I notice this row

let vSQL_Query= replace(replace(peek('sql_statement',0,'Table'),'Product','$(vproduct)'),'DB','$(vDB)');

Your peek are always looking at the same row, row 0. Maybe you need to use the variable i here as you do for the other peek statements.

let vSQL_Query= replace(replace(peek('sql_statement',$(i),'Table'),'Product','$(vproduct)'),'DB','$(vDB)');

I also notice that you loop is done on 'I' and not 'i' as expected in the peek statements. (But I assume that is just another spelling error)

 

dandaanilreddy
Partner - Creator III
Partner - Creator III
Author

@Vegar It worked. Thanks a lot.  🙂