summaryrefslogtreecommitdiff
path: root/tests/examplefiles/qlik/example.qvs
blob: f83604e204e69cd535138a48dc40484e26eadae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* ---------------------------------
This is an example file containing qlik script
--------------------------------- */

LET vFilePath = '/home';

FOR EACH vFolder IN 'folder_1', 'folder_2'

    // Check the file exists
    IF FILESIZE('$(vFilePath)/$(vFolder)/file.qvd') >0 THEN

        TABLE_NAME:
        NoConcatenate
        LOAD
            [Field 1]   AS FIELD_1,
            "Field 2"   AS FIELD_2,
            FIELD_3,
            FileName()      AS SOURCE_FILE_$(vFilePath),
            '$(vFilePath)/$(vFolder)/file.qvd'  AS [Expand_Brackets],
            '(This is a string)'            AS brackets_in_string
            'This costs $10'                AS dollar_in_string
        FROM
            [$(vFilePath)/$(vFolder)/file.qvd] (qvd);

        MAP_FIELD_1:
        MAPPING LOAD
            FIELD_1,
            SUM(FIELD_2)
        RESIDENT
            TABLE_NAME
        GROUP BY
            FIELD_1;

        LEFT JOIN(TABLE_NAME)
        load distinct
            FIELD_1,
            FIELD_2,
            FIELD_3,
            applymap('MAP_FIELD_1', FIELD_1, 0)     AS FIELD_2_SUM,
            'String' & ' ' & 'Concatenation'        AS single_quote_test,
            'Token String ''Name'''                 AS [String Field $(vFilePath)],
            3.14159                                 AS "Number Field $(vFilePath)",
            3 * 10 + 6 / 2 - 5                      AS OPERATION_FIELD
        Resident
            TABLE_NAME
        ORDER BY
            FIELD_3 DESC;

        STORE TABLE_NAME INTO [$(vFilePath)/$(vFolder)/file_output.qvd] (qvd);

        DROP TABLE TABLE_NAME;

    ELSE

        TRACE No file found in $(vFilePath)/file.qvd;

    END IF

NEXT vFolder