Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kakani87
Specialist
Specialist

Custom Current & Previous week Analysis

I should implement a requirement using transaction date In Qlikview , can someone assist here? 

@sunny_talwar 

Let say weekly analysis to be presented with week format as weekstart (date) &'-'& weekend (date ) i.e.  1/1/2022 - 1/7/2022 , 1/8/2022 - 1/14/2022 , 1/15/2022 - 1/21/2022 ... in a filter and that should  display the data Accordingly.

In a chart show product wise | current week sales | Previous week Sales . 

Note:- week format should be as weekstart& weekend as shown below 

Week,  salesAmt,  Item

1/1/2022 - 1/7/2022 , 1000, p1

1/8/2022 - 1/14/2022 ,254,p1

1/15/2022 - 1/21/2022,345, p1

1/1/2022 - 1/7/2022 , 1630, p2

1/8/2022 - 1/14/2022 ,294,p2

1/15/2022 - 1/21/2022,845, p2

1/1/2022 - 1/7/2022 , 1050, p3

1/8/2022 - 1/14/2022 ,654,p3

1/15/2022 - 1/21/2022,545, p3

Labels (1)
2 Replies
SunilChauhan
Champion
Champion


Test:
Load * Inline [
Week, salesAmt, Item

1/1/2022 - 1/7/2022 , 1000, p1

1/8/2022 - 1/14/2022 ,254,p1

1/15/2022 - 1/21/2022,345, p1

1/1/2022 - 1/7/2022 , 1630, p2

1/8/2022 - 1/14/2022 ,294,p2

1/15/2022 - 1/21/2022,845, p2

1/1/2022 - 1/7/2022 , 1050, p3

1/8/2022 - 1/14/2022 ,654,p3

1/15/2022 - 1/21/2022,545, p3
];

Load *
,Previous(salesAmt) as PreviousSales

Resident Test order by Item,Week;

Drop table Test;

IamBack_0-1667462514892.png

 

see the attached file

Sunil Chauhan
kakani87
Specialist
Specialist
Author

Hi sunil...  Thanks for your response.

Actually my requirement is not like you have shared.

Let say my table should be displayed with Data as below posted sample data 

Product|Currentweeksales|PreviousWeeksales  X,  10, 6

Y, 6,7

Z, 8,9

Now assume current week is 40th & previous week is 39th.

If I filter data that should dynamically filter the data accordingly.

In general we go for set expressions followed by for current & Previous as shown 

Current = Sum({<weeknumber={ ' $(=max( weeknumber) )'}>}sales )

Store variable as vPrevWeek= Max( Weeknumber)-1

Previous =Sum({<weeknumber={ ' $(=max( wvPrevWeek) )'}>}sales )

While there is a filter provided for weeknumber data as  40,39,38,37 ...

Now in my case user asked to enhance the filter with start date & end date of week in one filter to apply the filter accordingly while I did that by doing work around like  weekstart ( Trandate )&"-"weekend(Tran date ) As weekrange in back-end script. While I use this as a filter in front end this is not filtering data for previous week 

Same time I'm good with set expression using weeknumber but not using week filter as startdate&' '&enddate  (d/m/y ) format 

1/1/2022-1/7/2022

1/8/2022-1/14/2022

1/15/2022-1/21/022

.

.

.

 

Hope you got my  expectation .