Qlikview 按月生成 qvd

Qlikview generate qvd by month

我已经用左连接连接了两个 table 并将生成 qvd。我想根据日期的月份生成 qvd。例如,如果从 jan 到 dec 有 12 个日期,那么将有 12 个 qvd 文件。

您可以查看 Month 字段中的所有值。每次迭代将从中加载数据 TEMP_TABLE1 一个月并将此温度 table 存储到 qvd 文件中。

下面的脚本可以让您了解如何实现这一目标

// Load some data
RandData:
Load 
  *
Inline [
Value , Month
1     , Jan
2     , Feb
3     , Mar
4     , Apr
5     , May
6     , Jun
7     , Jul
8     , Aug
9     , Sep
10    , Oct
11    , Nov
12    , Dec
];

// Start looping through each distinct value in the Month field
for i = 1 to FieldValueCount('Month')
    // In-loop variable that will get the current increment value from the Month field
    let sMonhValue = FieldValue('Month', $(i));
    trace Storing data for Month --> $(sMonhValue);

    // NoConcatenate is used to tell Qlik to not concatenate the same tables
    NoConcatenate

    // Load the data for the current iteration month from the main data table
    TempTable:
    Load
      *
    Resident
      RandData
    where
      Month = $(i)
    ;

    // Store one month data in qvd. The name of the qvd will include the month value        
    Store TempTable into RandData_$(sMonhValue).qvd;

    // The Store statement above will store the qvd files next to the qvw file. 
    // If the qvd files need to be stored somewhere else - just provide the path like:
    //Store TempTable into c:\users\UserName\Documents\RandData_$(sMonhValue).qvd;

    // Drop the temp table. Otherwise it will get concatenated to the "previos" temp table 
    Drop Table TempTable;
next

// At the end the app will contain only one table - `RandData`