Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ben_skerrett
Contributor III
Contributor III

Store a value, to compare against the following month

Hi,
I am hoping someone can please help.
We have data downloaded from SAP on a daily basis.
Each day a figure is calculated, using the fields listed below.

On the 1st day of each month, I would like to save the calculated value, so I can compare it on the following month.
The issue I have, is when the data is loaded on a day which isn’t the first of the month, the incremental data is overwritten with blank values.

// Initial Load of planned cost
Qualify*;
Unqualify %SOI_Key;

PlanCost:
LOAD
%SalesDocumentAndItem as %SOI_Key,
CurrencyType,
KeyFigure,
Version,
Amount,
ValueType
FROM [lib://40.GlobalPM_QVD/PS_Plan_Cost.qvd]
(qvd);


// Only load Incremental data in first day of the month

if(day(Today()))='1’ then

Incremental:
LOAD
%SalesDocumentAndItem as %SOI_Key,
CurrencyType,
KeyFigure,
Version,
ValueType,
Amount
FROM [lib://40.GlobalPM_QVD/PS_Plan_Cost.qvd] (qvd);

Store Incremental into [lib://40.GlobalPM_QVD/JCP_Incremental.qvd] (qvd);


Thanks in advance
Ben



 

3 Replies
Or
MVP
MVP

Nothing in this code suggests it should be overwriting anything, though it's missing the END IF so hard to say what else might be causing it further down the line. It does look like this code will overwrite the value on the first of each month, though, so it only gets saved for that one specific month.

ben_skerrett
Contributor III
Contributor III
Author

Thank you for the reply.

Looking at the Data Model Viewer, the data is actually not getting over written, instead the Incremental table is simply not loading if today is not the first of the month.

 

I am hoping the following will work (I will change the 1st to the 11th, so hopefully tomorrow i will know if it has worked.  Thanks again.

 

Qualify*;
Unqualify %SOI_Key;

PlanCost:
LOAD
%SalesDocumentAndItem as %SOI_Key,
CurrencyType,
KeyFigure,
Version,
Amount,
ValueType
FROM [lib://40.GlobalPM_QVD/PS_Plan_Cost.qvd]
(qvd);

 

if(day(Today()))<>'1' then

Incremental:
LOAD
%SalesDocumentAndItem as %SOI_Key,
CurrencyType,
KeyFigure,
Version,
ValueType,
Amount
FROM [lib://40.GlobalPM_QVD/JCP_Incremental.qvd] (qvd);

else


Incremental:
LOAD
%SalesDocumentAndItem as %SOI_Key,
CurrencyType,
KeyFigure,
Version,
ValueType,
Amount
FROM [lib://40.GlobalPM_QVD/PS_Plan_Cost.qvd] (qvd);

Store Incremental into [lib://40.GlobalPM_QVD/JCP_Incremental.qvd] (qvd);

 

End If

Or
MVP
MVP

Looking at that code, it seems a bit wonky  - why are you reading from PS_Plan_Cost twice (only on the first of the month)? Also, it looks like this will fail since you are using Qualify * earlier in your script, then writing the qualified field names into the JCP_Incremental QVD, but when you are reading from that QVD you aren't using qualified names. Perhaps I'm missing something with that..?