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

Date Difference Calculation

Hi All,


Good Day!

I am currently working on a date calculation using QlikSense, I have a Customer column and an Order Date Column, and I need to calculate for the date difference between the customer orders and at the same time the average of the date difference of their orders. Please refer to the example below regarding the output of the date difference I am calculating for.

DateComputation.PNG

I've been working on this for quite a long time now but I can't get the result I wanted to see.

Hope you can help me on this. Thanks in advance for your help everyone.

12 Replies
sunny_talwar

Try this:

Table:

LOAD * Inline [

Customer, Order Date

A, 1/2/2015

A, 1/5/2015

A, 1/10/2015

B, 5/6/2015

C, 3/2/2015

C, 3/20/2015

C, 4/1/2015

C, 4/8/2015

D, 1/8/2015

D, 1/13/2015

];

Join(Table)

LOAD Customer,

  [Order Date],

  If(Customer = Peek(Customer), [Order Date] - Peek('Order Date')) as [Date Difference]

Resident Table

Order By Customer, [Order Date];

Join(Table)

LOAD Customer,

  Avg([Date Difference]) as [Avg Difference]

Resident Table

Group By Customer;

Join(Table)

LOAD Customer,

  Num(Today()) - MaxOrderDate + 1 as [Days since Last Order];

LOAD Customer,

  Max([Order Date]) as MaxOrderDate

Resident Table

Group By Customer;

Anonymous
Not applicable
Author

Hi sunindia,

 

  It works! Thank you so much for your help.

  I appreciate your prompt response. Thanks again.

regards,

Damien

sunny_talwar

No problem Damien

I am glad I was able to help.

Best,

Sunny