Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Does Qlik have the ability to create functions similar to TSQL functions?

Sorry if this has been asked before but does Qlik enable you build functions?
In SQL Server we would have build a procedure or function to achieved complex row by row analysis, is there something similar in Qlik?

Thanks for any help.

Steve

8 Replies
marcus_sommer

Yes, there is with interrecord-functions like: Peek() or Previous() ?

- Marcus

sasiparupudi1
Master III
Master III

Qlik will only allow you to write user defined procedures in the syntax similar  to that of VB. No user defined functions possible.

ex:

sub myProc

your logic

End Sub

marcus_sommer

User defined functions could be implemented by variables with parameters:

Variable That Acts Like a User-Defined Function.

Dynamic Field Expressions with Variables

Variables with Parameters

- Marcus

sasiparupudi1
Master III
Master III

I agree but they are not quite the same as a procedure/function where one can write some complex logic

Best

marcus_sommer

Surely some things might require more efforts but others will be even easier as in (T)SQL so that I think that everything what could be done in (T)SQL could be done in Qlik too, but in different ways. Further I think that adapting the logics to the way Qlik works is better as trying to keep the SQL logic at least if one want to use the advantages of Qlik.

- Marcus

Anonymous
Not applicable
Author

Thanks Guys

I have also been looping at resident tables and loops.

Would it make sense to do something like the following?

1 Load up a distinct list of custmers from a resident table

2 Loop through each customer

3 Load up a temporary table of transaction records for the specific customer in the loop

4 Copy the customer record and processing to another table

5 Drop the temporary table

6 Loop to the next customer

Essentially being left with a copy of the data with the processing for each customer?

There could be a better way and I am limiting myself to relational DB thinking... but basically using the resident tables as curors and loops in TSQL

marcus_sommer

1/2 don't need a resident load because a loop over the fieldvalues would be enough like here:

Re: For each - get a second value associated

For 3 could the for each variable be used as filter within the where-clause.

By 4 I don't understand the meaning what should happens.

5 just add: drop table YourTableName;

6 see to 1/2

But what is the aim to create a single table for each customer - it don't seemed to be a store as file so it's related to 4?

- Marcus

naveenkumarchin
Partner - Contributor III
Partner - Contributor III

In Qlik, you can create functions and also sub routines.

For sub routines , you would use Sub Routine_name() .... End Sub;

For Functions, You would Function Function_name() ..... End Sub;