Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

Generate QVD of the subsequent month

I created a routine to capture the information of some documents and these are divided by competence (date of payment). It turns out that the created routine reads the files until the current month (current), that is, if we are in February, it does not read the March file. Now I need to read at least a month ahead, but I can not do that, because in February I'm already getting the files that refer to March.

Example: Currently because we are in February, the script loads the files that exist until february.

Screenshot_1.png

I need the script to also load the files until the later month, that is, until March (2019_03)

Screenshot_2.png

I've attached the QVF, the files I'm currently using, and the worksheet to configure QVD loading.

Thanks in advance for your attention and help.

🙂

 

Labels (2)
1 Reply
Highlighted
Contributor III
Contributor III

Re: Generate QVD of the subsequent month

I imagine that the adjustment should done in this piece of code so that it is possible to read all the files regardless of the date. I need to read at least until the month after the current one, but if I read every future month, there would be no problem.

//-------------------------Define Variavel com os valores de Periodos------------------------------------

Periodos: LOAD Periodos, QtdeMesesAsterisco, QtdeMesesFolga FROM [$(ARQParametro)] (ooxml, embedded labels, table is Periodos);
LET Periodos=FieldValue('Periodos',1);
DROP Table Periodos;

IF '$(Periodos)'='*' THEN
	//-------------------------Define o número de meses que serão carregados ----------------------
	QtdeMesesAsterisco: LOAD QtdeMesesAsterisco FROM [$(ARQParametro)] (ooxml, embedded labels, table is Periodos);
	LET QtdeMesesAsterisco=FieldValue('QtdeMesesAsterisco',1);
	DROP Table QtdeMesesAsterisco;
	
	QtdeMesesFolga: LOAD QtdeMesesFolga FROM [$(ARQParametro)] (ooxml, embedded labels, table is Periodos);
	LET QtdeMesesFolga=FieldValue('QtdeMesesFolga',1);
	DROP Table QtdeMesesFolga;

	IF '$(QtdeMesesFolga)'<1 or '$(QtdeMesesFolga)'=Null() then
		LET QtdeMesesFolga = 0;
	ENDIF	

	LET DataFim = MonthStart(AddMonths(Today(),-$(QtdeMesesFolga)));
	LET DataInicio = MonthStart(AddMonths('$(DataFim)',-$(QtdeMesesAsterisco)+1));
	LET Periodos = '';
	
	DO
		LET Periodos = '$(Periodos)' & Num(Month('$(DataInicio)'),'00') & Year('$(DataInicio)');
		IF '$(DataInicio)'<'$(DataFim)' then 
			LET Periodos = '$(Periodos)' & ',';
		ENDIF
		LET DataInicio = AddMonths('$(DataInicio)',1);
		
		IF '$(QtdeMesesAsterisco)'<1 or '$(QtdeMesesAsterisco)'=Null() then
			LET DataInicio = AddMonths('$(DataFim)',1);
			LET Periodos = '';
		ENDIF
	LOOP while '$(DataInicio)'<='$(DataFim)';
ENDIF
LET PeriodosFatos = '$(Periodos)';