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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can create a function ?

Hi,

I try to know how I can call a function.

ex:

I make a table:

LOAD

    *

FROM

    Documents



and now I want to use this table in each other table I have without copy/past. Until now I put this table into a variable and I wonder if is it work.

Regards

19 Replies
Anonymous
Not applicable
Author

Not sure that I understand your question.  Could you clarify ?

Not applicable
Author

Actually I try to show all error that my apply can make. And I have this:

SET vError = FIRST 1 CONCATENATE(ERROR) LOAD

  COUNTRY_CODE,

  '$(NbRows)' as NB_ROWS,

  '$(ScriptErrorCount)' as ERROR_SEQ_NUMBER,

  '$(#ScriptError)' as ERROR_ID,

  '$(ScriptError)' as ERROR_NAME,

  '$(ScriptErrorDetails)' as ERROR_DETAIL,

  '$(ScriptErrorList)' as ERROR_LIST,

  now() as ERROR_DATE

resident COUNTRY;



I want to put this script into every table I have to check and put into a table. And i wonder if this way to work is correct or there's other way to make it.

alexandros17
Partner - Champion III
Partner - Champion III

Simply use an alias as a name for the table:

MyTable:

LOAD

    *

FROM

    Documents;

Now you can use MyTable for example:

Load * resident MyTable;

undergrinder
Specialist II
Specialist II

Hi!

If you specify your problem, then we may help you.

You can create a function with a VB like script.

eg:

Sub function ()

    LOAD

        *

    FROM

        Documents

end sub


call function



In Chart and function guide there is some example (https://help.qlik.com/sense/en-us/pdf/Script%20Syntax%20and%20Chart%20Functions%20Guide.pdf)

I'm not sure, that is it, what you want.

HTH

G.

CELAMBARASAN
Partner - Champion
Partner - Champion

Variables can hold a single value, it doesn't store the table.

You have load the table and keep a name for that and use as needed.

To use previously loaded table into memory then

Load *

Resident TableName;

Not applicable
Author

Then, I have to write this table each time I have to use? Because, actually I have to manage a lot of table and if I put this table in each table, the day that I have to correct it will be a little complexe no ?

CELAMBARASAN
Partner - Champion
Partner - Champion

What is your expectation, how you are going to use this table?

Not applicable
Author

SET vError = FIRST 1 CONCATENATE(ERROR) LOAD

  COUNTRY_CODE,

  '$(NbRows)' as NB_ROWS,

  '$(ScriptErrorCount)' as ERROR_SEQ_NUMBER,

  '$(#ScriptError)' as ERROR_ID,

  '$(ScriptError)' as ERROR_NAME,

  '$(ScriptErrorDetails)' as ERROR_DETAIL,

  '$(ScriptErrorList)' as ERROR_LIST,

  now() as ERROR_DATE

resident COUNTRY;


//**********************************************************************//


my_table1:

load

    *

From

    Documents;


SET vError;


my_table2:

load

    *

From

    Documents;


SET vError;


my_table3:

load

    *

From

    Documents;


SET vError;


/****************************************************/


I have this, I want to know if there's something to call  "SET vError" as a variable can only have a single value.

Is it mandatory to put "SET vError" table in every tables ?

marcus_sommer

In general such an approach will work with:

SET vError = "CONCATENATE(ERROR)

LOAD FIRST 1

  COUNTRY_CODE,

  '$(NbRows)' as NB_ROWS,

'$(ScriptErrorCount)' as ERROR_SEQ_NUMBER,

  '$(#ScriptError)' as ERROR_ID,

  '$(ScriptError)' as ERROR_NAME,

'$(ScriptErrorDetails)' as ERROR_DETAIL,

  '$(ScriptErrorList)' as ERROR_LIST,

  now() as ERROR_DATE

resident COUNTRY;"

and called simply with:

$(vError)

but the syntax-checker won't recognize them as correct and it is not flexible. Therefore I suggest you to put this into a include-variable and extended it to a generic table like:

include-file:

let vLoadTable = TableName(NoOfTables() - 1);

CONCATENATE(ERROR)

LOAD FIRST 1

  COUNTRY_CODE,

  '$(NbRows)' as NB_ROWS,

'$(ScriptErrorCount)' as ERROR_SEQ_NUMBER,

  '$(#ScriptError)' as ERROR_ID,

  '$(ScriptError)' as ERROR_NAME,

'$(ScriptErrorDetails)' as ERROR_DETAIL,

  '$(ScriptErrorList)' as ERROR_LIST,

  now() as ERROR_DATE

resident $(vLoadTable);

and adds maybe some more useful informations like documentname(), today() ... and so on - see for include: The $(Include) which you $(Must_Include) into your toolkit

- Marcus