Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Raju_6952
Creator III
Creator III

Automatic qvd creation

// Step 1: Load the data from CSV files

TempData:

LOAD *,

    Date(Start_Timestamp, 'YYYY-MM') AS MonthField

FROM [$(vBLR_PATH)Self Serv Report/IFR/INTERACTION_FLOW_REPORT_*.csv]

(txt, codepage is 28591, embedded labels, delimiter is ',', msq);

 

// Step 2: Iterate over the distinct months

FOR EACH _month IN FieldValueList('MonthField')

    LET vYearMonth = _month;

    

    TRACE Processing Month: $(vYearMonth); // Add logging for debug

 

    // Step 3: Create a new dataset for each month

    MonthData:

    NoConcatenate

    LOAD * 

    RESIDENT TempData

    WHERE Date(Start_Timestamp, 'YYYY-MM') = '$(vYearMonth)';

 

    TRACE Storing Month Data for: $(vYearMonth); // Add logging for debug

 

    // Step 4: Store the data for the current month into a QVD

    STORE MonthData INTO [$(vQVD_PATH)Self Serv/IFR_$(vYearMonth)_new.qvd] (qvd);

 

    // Step 5: Drop the temporary month data

    DROP TABLE MonthData;

NEXT _month;

 

// Step 6: Clean up TempData

DRO

P TABLE TempData;

Will this script works 

EXIT SCRIPT;

Labels (1)
1 Reply
PrashantSangle

Try below code

// Step 1: Load the data from CSV files

TempData:

LOAD Distinct

MonthStart(Start_Timestamp, 'YYYY-MM') AS MonthField

FROM [$(vBLR_PATH)Self Serv Report/IFR/INTERACTION_FLOW_REPORT_*.csv]

(txt, codepage is 28591, embedded labels, delimiter is ',', msq);


// Step 2: Iterate over the distinct months
For i=0 to NoOfRows('TempData')

Let Monthfield =Peek('MonthField',$(i),'TempData');

// Step 3: Create a new dataset for each month
MonthData:
NoConcatenate
LOAD *
FROM [$(vBLR_PATH)Self Serv Report/IFR/INTERACTION_FLOW_REPORT_*.csv]
WHERE MonthStart(Start_Timestamp, 'YYYY-MM') = '$(Monthfield)';

// Step 4: Store the data for the current month into a QVD
STORE MonthData INTO [$(vQVD_PATH)Self Serv/IFR_$(Monthfield)_new.qvd] (qvd);

// Step 5: Drop the temporary month data

DROP TABLE MonthData;

Next i;

// Step 6: Clean up TempData

DROP TABLE TempData;

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂