# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for
Did you mean:
Creator

## Set analysis

Hi,

i would like to select a customer and be able to see how many days go between the last sale and the previous one.

Thanks.

2 Solutions

Accepted Solutions
Master II

@Carlaf_93  I understood no need to do a set analysis.

for exampe :

if I selected A as customer :

max(date)->14/06/2020

previous one->01/05/2020

So to calculate nbr of days u can use :

``=Floor(Date(Max(Date)))-Floor(Date(Max(Date,2)))``

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Master II

Can you share with me how you calculate 33, because :

between 19/03 and 12/02 ->35 days

between 23/04 and 19/03 ->35 days

between 23/05 and 23/04 ->30 days

between 19/06 and 23/05 ->27 days

the avg thus is 31.75

Script:

``````=Avg(
aggr(
floor(DATE_A)-floor(above(DATE_A))
,CUSTOMER,DATE_A

)
)``````

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
6 Replies
Master II

@Carlaf_93  I understood no need to do a set analysis.

for exampe :

if I selected A as customer :

max(date)->14/06/2020

previous one->01/05/2020

So to calculate nbr of days u can use :

``=Floor(Date(Max(Date)))-Floor(Date(Max(Date,2)))``

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Creator
Author

Thank you!

And if i want the average number of days between all the sales of one customer?

Master II

can you share a sample data and the expected value of the avg ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Creator
Author

DATE_A, CUSTOMER, SALES,

12/02/2019, A, 3,

19/03/2019, A, 30,

23/04/2019, A, 7,
23/05/2019, A, 7,

19/06/2019, A, 3,
];

I expect an average of 33 days for customer A

Master II

Can you share with me how you calculate 33, because :

between 19/03 and 12/02 ->35 days

between 23/04 and 19/03 ->35 days

between 23/05 and 23/04 ->30 days

between 19/06 and 23/05 ->27 days

the avg thus is 31.75

Script:

``````=Avg(
aggr(
floor(DATE_A)-floor(above(DATE_A))
,CUSTOMER,DATE_A

)
)``````

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Master II

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Tags
Community Browser