Here is to the start of a new blog series I am doing called ‘101 Things I Wish I Had Known Sooner’. Each post will contain a straight and to the point thing that I, well… wish I had known sooner. To start it off I am going to talk about Qlik Subroutines.

A subroutine is a user defined program within your script that you can call at a later time.

For example:

Sub RowCount(pRowTable)


    Let RC.Rows = Num(NoOfRows('$(pRowTable)'),'#,##0');

    Trace ---------------- $(pRowTable): $(RC.Rows) rows;

    RC.Rows=;

End Sub;


Fact:
Load
    Rand() as Random
AutoGenerate
    (1000);

Temp:
Load
    Chr(IterNo()) as Char
AutoGenerate
    (1)
While
    IterNo() <= 2;

Outer Join(Fact)
Load
    Char
Resident
    Temp;

Drop Table Temp;


CALL RowCount('Fact');

Which returns:

This is a very simple example, but you can start to see the possibilities.