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

Comparing counts from a day with 7 days before

Hi,

I have data like this

Date Noindiv

20110101 123123123

20110101 423423423

20110107 45t4terterter

20110107 123123123

20110107 423423423

I would like to count the number of Noindiv and compare it with the date 7 days before

Date daycount 7days before daycount

20110107 3 2

Any idea ?

I am trying to use a set analysis function, but it does not work.

Thanks

Philippe

1 Solution

Accepted Solutions
Not applicable
Author

Maybe you could use this:


temp:
LOAD * INLINE [
Date, Noindiv
20110101, 123123123
20110101, 423423423
20110107, 45t4terterter
20110107, 123123123
20110107, 423423423
];

temp2:
load Date,
count(Date) as CountDate
resident temp
group by Date
order by Date;
drop table temp;

Data:
load Date,
CountDate,
if(Date<>previous(Date),previous(CountDate)) as PreviousCount
resident temp2;
drop table temp2;


View solution in original post

4 Replies
Anonymous
Not applicable
Author

It will be:
Date
daycount = count(Noindiv)
"7 days before count" = count({$<Date={"$(=date(Date-7))"}>} Noindiv)

Edit: Assuming that you select one Date.

Not applicable
Author

Thanks Michael for the answer.

What would be the answer if I do not select any date but I want to show the difference between the two dates in a graph ?

Thanks

Philippe

Not applicable
Author

Maybe you could use this:


temp:
LOAD * INLINE [
Date, Noindiv
20110101, 123123123
20110101, 423423423
20110107, 45t4terterter
20110107, 123123123
20110107, 423423423
];

temp2:
load Date,
count(Date) as CountDate
resident temp
group by Date
order by Date;
drop table temp;

Data:
load Date,
CountDate,
if(Date<>previous(Date),previous(CountDate)) as PreviousCount
resident temp2;
drop table temp2;


Not applicable
Author

Thanks a lot ,

That works well !!!

Philippe