Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Slowly Changing Dimension

Hi,

Can anyone explain me this part ?

Let vEpsilon = Pow(2,-37);

Load

Autonumber(SPID & '|' & FromDate & '|' & ToDate) as [SPID+Interval],

*;

LOAD

Date#(FromDate, 'YYYY-MM-DD') as FromDate,

Date(Date#(ToDate, 'YYYY-MM-DD') - $(#vEpsilon)) as ToDate,

Why we are using this Pow()?....Why we are subtracting this variable vEpsilon?  What is the need?


Attachment for full coding

1 Reply
sunny_talwar

From what I understand, the script is doing a interval match on dates, but these dates might have looked like this

FromDate,     ToDate

01/01/2018     02/01/2018

02/01/2018     03/01/2018

03/01/2018     04/01/2018

As you might see 02/01/2018 is found in both Row1 and Row2... in order to solve this problem, the script is subtracting a very very small number from 02/01/2018 in the first row.

Pow() is just a power function. So, 2 raise to the power of -37 is what we are subtracting from ToDate to make it slighly less than 02/01/2018... may be like 01/31/2018 23:59:59 and some micro seconds....