Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

aggregating daily to weekly data

Good Afternoon all,

I have a table at present that looks like the below:

DateTotal
01/01/20134
02/01/20132
03/01/20136
04/01/20138
05/01/20132
06/01/20131
07/01/20132
08/01/20138
09/01/20138
10/01/201310
11/01/20134
12/01/20138
13/01/20137
14/01/20138

I am looking to use set analysis to group this into weeks so the table looks like this:

DateTotal
07/01/201325
14/01/201353

I would be very grateful for any help that anyone can provide

Many thanks

Mike

1 Solution

Accepted Solutions
v_iyyappan
Specialist
Specialist

Hi,

Script:

LOAD

    *,

    Week(Date(Date#(Date1,'DD/M/YYYY'))) AS Week,

    WeekName(Date(Date#(Date1,'DD/M/YYYY'))) AS WeekYear;

LOAD * INLINE

[Date1, TotalData

    1/01/2013,4

    2/01/2013,2

    3/01/2013,6

    4/01/2013,8

    5/01/2013,2

    6/01/2013,1

    7/01/2013,2

    8/01/2013,8

    9/01/2013,8

    10/01/2013,10

    11/01/2013,4

    12/01/2013,8

    13/01/2013,7

    14/01/2013,8

];

Use expression like

Dimension WeekYear and expression = Sum(TotalData)

View solution in original post

3 Replies
datanibbler
Champion
Champion

Hi Mike,

just switch the dimension and use the SUM() fct.

HTH

Best regards,

DataNibbler

Not applicable
Author

I would suggest a minor change to your script.

Add:  Week(Date) as Week

or:     Week(Date)&'-'&Year(Date)     as     WeekYear

to the table that also holds the date.

Having done that you're able to use SUM(Total) to find the sumarised total you're looking for

v_iyyappan
Specialist
Specialist

Hi,

Script:

LOAD

    *,

    Week(Date(Date#(Date1,'DD/M/YYYY'))) AS Week,

    WeekName(Date(Date#(Date1,'DD/M/YYYY'))) AS WeekYear;

LOAD * INLINE

[Date1, TotalData

    1/01/2013,4

    2/01/2013,2

    3/01/2013,6

    4/01/2013,8

    5/01/2013,2

    6/01/2013,1

    7/01/2013,2

    8/01/2013,8

    9/01/2013,8

    10/01/2013,10

    11/01/2013,4

    12/01/2013,8

    13/01/2013,7

    14/01/2013,8

];

Use expression like

Dimension WeekYear and expression = Sum(TotalData)