Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bharatkishore
Creator III
Creator III

Previous Week

Hi All,

I have a week column from excel and i have  sales and super sales... Now i need show data for previous week.

The formula for calculating is sales/supersales for previous week.

Can you please help me on this.

Thanks,

Bharat

1 Solution

Accepted Solutions
Anonymous
Not applicable

your weekfield is a datefield, so you Need to define a new field

for example:

Sales:
load * Inline [
Brand, Week, Sales, SuperSales
A, 12.07.2015, 2836, 118
A, 14.12.2015, 2242, 106
A, 21.12.2015, 3751, 147
]
;

left join(Sales)
load *,
week(Week) as WeekNr
Resident Sales;

then you can use this Expression:

=sum({<WeekNr={'$(=max(WeekNr)-1)'}>}Sales/SuperSales)

you my use eitehr Week  or WeekNr as dimension

if you use a mastercalendar (the best choice anyway) you may Need the weekfield from mastercalendar

View solution in original post

12 Replies
Anonymous
Not applicable

if you have week as number in Excel upto current week

you Need this Expression:

sum({<yourweekfield={'$(=max()yourweekfield)'}>}sales)

if you have not only actual year you Need mroe set analysis

Anil_Babu_Samineni

Hello,

LOAD

          DateField,

          Autonumber(Weekstart(DateField), 'Week') as WeekDateField,

          ... FROM .....

Expressions Are:

1) =Sum({<WeekDateField = {'$(=Max(WeekDateField)-1)'}>}Sales)

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
Anonymous
Not applicable

sum({<yourweekfield={'$(=max(yourweekfield)-1)'}>}sales)

bharatkishore
Creator III
Creator III
Author

Hi Linder

Thanks for your reply..

I need to calculate sales/supersales which should display data for last week.. i m displaying in barchart and it should happen without filters.

Anonymous
Not applicable

what is your Dimension? weekfield

and your Expression?

and your data from Excel contains data sales/supersales from this year

so you may use my Expression: sum({<yourweekfield={'$(=max(yourweekfield)-1)'}>}sales/supersales)

or you define a calulated Dimension: if (yourweekfield = week(today()-1, yourweekfield) and

Expression sum(sales/supersales)

bharatkishore
Creator III
Creator III
Author

I have given the following expression:

=sum({<Week={'$(max(Week)-1)'}>}Sales/SuperSales)

but i am getting the value as 0. Can you please let me know if i missed something..

Dimension i have taken as Brand

Anonymous
Not applicable

can you give me some figures so i can try a small sample?

Anonymous
Not applicable

sorry Little mistake (equal sign was missing before max)

=sum({<Week={'$(=max(Week)-1)'}>}Sales/SuperSales

I defined inline table and defined Week as Dimension and above expression

Sales:
load * Inline [
Week, Sales, Supersales
24, 100, 10
24, 150, 5
25, 200, 10
]
;

bharatkishore
Creator III
Creator III
Author

Please find the attached excel.