Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
zied_ahmed1
Contributor III

Calculate the number of x for the previous 4 weeks

Hello,

I have an excel file and i need to calculate the number of values for the last 4 weeks (based in today date) 

For example we are in 26 December so i need to have the numbers of values for the last 4 weeks 

how to do it 

 

Thank you 

 

 

4 Replies
zied_ahmed1
Contributor III

Re: Calculate the number of x for the previous 4 weeks

Untitled.png

Re: Calculate the number of x for the previous 4 weeks

If you already have Week as Field, You can define  as

Sum({<Week = {">=$(=Max(Week-4))<=$(=Max(Week))"}>} Measure) // I assume, Week is in Number format

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
zied_ahmed1
Contributor III

Re: Calculate the number of x for the previous 4 weeks

I don't have any field i have just the file like the picture...

Re: Calculate the number of x for the previous 4 weeks

For your case, Transformation needed using CrossTable() function. After done that, You need to arrange like

Sum({<DateField = {">=$(=Week(Date(Max(Date#(DateField, 'DD-MMM-YY')),'DD-MM-YYYY'))-4)<=$(=Week(Date(Max(Date#(DateField, 'DD-MMM-YY')),'DD-MM-YYYY')))"}>} Measure)

Or, If you have only specific dates without historical data use this

Sum({<DateField = {">=$(=Date(Max(Date#(DateField, 'DD-MMM-YY'))-4,'DD-MM-YYYY'))<=$(=Date(Max(Date#(DateField, 'DD-MMM-YY')),'DD-MM-YYYY'))"}>} Measure)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)