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

how to make multiple date dimention

Hi All,


I have one access_log table.


accessed_timeuser_id
2013/11/11
2013/11/22
2013/11/51
2013/11/101

I want to count everyday's unique accessed users in past 7 days, like below:

7daysunique_users
11/1 - 11/730
11/2 - 11/810
11/3 - 11/911
11/4 - 11/1015
11/5 - 11/1118

I tried a lot of approach, to target multiple datetime in one dimension record , using above function, referencing dimension value from expression, etc...  But all I did didn't work

Is it possible?


Abe

1 Solution

Accepted Solutions
Not applicable
Author

Finally I made it

I made master calendar and date_dimension table as below:

master calendar

LOAD

gen_date as DateId,

year(gen_date) as ACCESSED_TIME_year,

month(gen_date) as ACCESSED_TIME_Month,

day(gen_date) as ACCESSED_TIME_Day,

weekday(gen_date) as ACCESSED_TIME_WeekDay,

week(gen_date) as ACCESSED_TIME_Week

;

 

LOAD

Date(floor(od_min + iterno() - 1),'YYYY-MM-DD') as gen_date

WHILE iterno() <= od_max - od_min + 1;

LOAD

min(ACCESSED_TIME) as od_min,

max(ACCESSED_TIME) as od_max

RESIDENT access_log

GROUP BY 1;

dimension table

LOAD

distinct

DateId - IterNo() + 1 as DateId,  

DateId as DateId_dim

resident master_Calendar

while DateId - IterNo() + 1 > DateId -7;

One DateId has 7 days. Using DateId as dimension I've got what I need.

Thanks all!

View solution in original post

5 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Why dont you create a Master Calender and then use that as a dimension to your chart.

     Kindly provide sample data.

Regards,

Kaushik Solanki   

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
hic
Former Employee
Former Employee

You should create a Master Calendar, just as Kaushik suggests. There are many resources on QlikCommunity that describes this, e.g. http://community.qlik.com/blogs/qlikviewdesignblog/2012/10/16/the-master-calendar

In the master calendar, you should create a field for your 7-day periods, e.g. using Week() or WeekStart() with an offset. This field can then be used as dimension.

HIC

Not applicable
Author

Thnks!

I've created Master Calendar. It seems really useful.

but how to make 7-day periods dimension ?

hic
Former Employee
Former Employee

All you need to do is to create a field (in your master calendar) that specifies to which 7-day period this date belongs. You can for instance use

  Week(Date)

which will give you the week number (week starts on Monday), or

  WeekStart(Date,0,-1)

which will give you the date of the first week day (week starts on Sunday). By changing the third parameter, you can make the "week" begin any day you want.

HIC

Not applicable
Author

Finally I made it

I made master calendar and date_dimension table as below:

master calendar

LOAD

gen_date as DateId,

year(gen_date) as ACCESSED_TIME_year,

month(gen_date) as ACCESSED_TIME_Month,

day(gen_date) as ACCESSED_TIME_Day,

weekday(gen_date) as ACCESSED_TIME_WeekDay,

week(gen_date) as ACCESSED_TIME_Week

;

 

LOAD

Date(floor(od_min + iterno() - 1),'YYYY-MM-DD') as gen_date

WHILE iterno() <= od_max - od_min + 1;

LOAD

min(ACCESSED_TIME) as od_min,

max(ACCESSED_TIME) as od_max

RESIDENT access_log

GROUP BY 1;

dimension table

LOAD

distinct

DateId - IterNo() + 1 as DateId,  

DateId as DateId_dim

resident master_Calendar

while DateId - IterNo() + 1 > DateId -7;

One DateId has 7 days. Using DateId as dimension I've got what I need.

Thanks all!