Good day,
I am in the process of migrating a Qlikview report into Power BI. I have not encountered the previous()
function before. I am attempting the same result with a SQL LAG()
function, but this is simply not working for me as I understand it.
The Qlikview function is as follows:
LOAD
if(sourceid = previous(sourceid) and serviceid = previous(serviceid),interval(rdate - previous(timestamp(rdate)),'D'),0) as days_interval
resident dialed
order by source_id, rdate, load_id
I have attemptred the following BigQuery script, but with no luck. Perhaps I am missing something in the Qlikview logic that isn’t the same as LAG()
?
IF(
dialed.source_id = LAG(dialed.source_id) OVER (ORDER BY dialed.rdate) AND dialed.service_id = LAG(dialed.service_id) OVER (ORDER BY dialed.rdate),
TIMESTAMP_DIFF(dialed.rdate, LAG(dialed.rdate) OVER (ORDER BY dialed.rdate), DAY),
0
)
Is anyone familiar with the previous()
function, and perhaps a better way to code it up in BigQuery?