Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
glenn2460
Contributor II
Contributor II

Days between dates - Previous() function?

I'm loading an attached XLS which contains the fields Date, Time, Latitude, Longitude.

The date field is in the format MM/DD/YYYY.

There are twenty rows of data and I have loaded it into a table chart which is sorted ASC by Date, ASC by Time.

The goal is to create a master measure which calculates the days between each consecutive row.

For example, the first date is 10/17/2019 and the second date is 10/21/2019.  The master measure should return 4 for the second row (diff between 10/21/2019 and the preceding 10/17/2019).   Obviously there will be an error generated for the first row since there is no preceding value.

I've been trying to use the Previous() function but having no success.  I thought something like [Time] - Previous([Time]) but I'm getting a null result.

Any assistance would be most appreciated.

Thanks.

Glenn

1 Reply
petter
Partner - Champion III
Partner - Champion III

I prefer to use Peek() instead of Previous(). Peek will look at the previous loaded value of a field (unless you specify an offset to look further back). Previous() look at a previous record of the source table.

First of all make sure that you date field is interpreted as date when loaded into Qlik. And that the time field is interpreted as a time. Both can be loaded as a single datetime field and then it is easier to calculate lapsed time also across days.