Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
dpietersz
Creator
Creator

How to calculate how many days a Sale was in a particular stage

Hi,

I have the follwing situation. I have a SQL data source with Sale details. Every time you edit a sale, the previous record of the sale is moved to a History table.

My first goal is to calculate how many days a sale record has been in a particular stage / probability phase.

In the history table I have a column "Updated". This shows me the date the record was updated.

I think I need this column to calculate the days between the different probability phases of a sale record.

But I don't know how and where to begin.

Anyone got some suggestions?

1 Solution

Accepted Solutions
yblake
Partner - Creator II
Partner - Creator II

Hi, I use the "previous" function to calculate cumulated elapsed days between events by contact. It may help you :

duration:
load
ID_EVENT,
ID_CONTACT,
EVENT_DATE,
if(ID_CONTACT<>previous(ID_CONTACT),0,EVENT_DATE-Previous(EVENT_DATE)) as ELAPSED_DAYS
resident events
order by
ID_CONTACT,
EVENT_DATE
;

View solution in original post

3 Replies
yblake
Partner - Creator II
Partner - Creator II

Hi, I use the "previous" function to calculate cumulated elapsed days between events by contact. It may help you :

duration:
load
ID_EVENT,
ID_CONTACT,
EVENT_DATE,
if(ID_CONTACT<>previous(ID_CONTACT),0,EVENT_DATE-Previous(EVENT_DATE)) as ELAPSED_DAYS
resident events
order by
ID_CONTACT,
EVENT_DATE
;

dpietersz
Creator
Creator
Author

Thanks Yves,

I will give it a try. I will let you know if it has done the job for me in that way.

dpietersz
Creator
Creator
Author

That did the job for me! Thx