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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
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)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful