Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
zied_ahmed1
Specialist
Specialist

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
Specialist
Specialist
Author

Untitled.png

Anil_Babu_Samineni

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

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

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
Specialist
Specialist
Author

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

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)

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

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)