【问题标题】:Qlikview generate qvd by monthQlikview 按月生成 qvd
【发布时间】:2025-12-08 15:00:02
【问题描述】:

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

【问题讨论】:

    标签: sql qlikview qliksense


    【解决方案1】:

    您可以查看Month 字段中的所有值。每次迭代都会从 TEMP_TABLE1 一个月并将这个临时表存储到一个 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`
    

    【讨论】:

    • 嗨,代码确实创建了 12 个 qvd,但只有第一个 qvd 有数据,其余的没有任何数据。我没有月份字段。仅到达格式为 05=06=18 0 - 六月和 05-07-18 - 七月的 dt。
    • 嗨,我将这个 MonthName("ARRIVE_DT") 添加为 MONTH_NAME,//找出数据中存在的月份名称以使用到达 dt 中的月份名称..并生成从 6 月到 9 月的 qvd但所有 qvd 中都没有数据
    • 只需使用您提供的代码运行 qvw,它也会返回空值。可以有一个包含所有月份生成数据的样本吗?谢谢