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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

From daily to weekly data

I've daily data (number of ...) and I would like to get data for the first day of the week. Data are as below:

dayweeknumber
01-gen13
02-gen16
03-gen14
04-gen19
05-gen112
06-gen132
07-gen12
08-gen26
09-gen24
10-gen28
11-gen21
12-gen20
13-gen212
14-gen24


and I would like to get only number 3 for week 1 and 6 for week 2 (first day of the week).

Thank you very much for your help,

r.

Labels (1)
3 Replies
Not applicable
Author

You could probably do something in your load or in an expression.

In your load, you could add a flag field. Something like first_day and make it Y for the first days and N for everything else.

You could use a day of the week function to determine which days should be marked. In Oracle, you could use: to_char(day, 'D') to give you the day of the week. You could then use a CASE statement to, fo example, mark the 0s as first_day = Y and the rest N.

If you want to handle it in an expression, you can use the built in QlikView day of the week function. Within QlikView it is weekday(Date), which will return 0-6 for a numerical day of the week.

Not applicable
Author

Not quite sure if this is what you're looking for, but based on you'r original post I got this to work...

I had to change your 'day' column (01-gen, 02-gen...) into a date (01/Jan/2009, 02/Jan/2009...). Then I was able to use this expression to get what you are looking for:

=Sum( If(day=Aggr(Min(day),week), number))

The aggr function finds the minimum day for each week, then the if statement checks the day of each row to see if it is in the result set that Aggr() returned. If it is then it passes the value from the 'number' field to the Sum().

In aggregate I get a value of 9. If I throw in a week dimension, and break this by dimension, then for week 1 I get a value of 3 and for week 2 I get a value of 6, which I believe is what you wanted.

Hope this helps.

sjprows

Anonymous
Not applicable
Author

r.,
Assuming that the "first day of the week" is Monday:


LOAD DISTINCT
week,
number
FROM <your table>
WHERE weekday(day)=0