Using the Previous() function to identify the latest record read for a dimensional value
In a line-level table, there are multiple records stored for a single dimensional value. For example, an Order Line
table will have multiple lines for the same OrderID
. Business requirements may warrant us to only consider the first or the latest line for each order. This can be done using the Previous()
function available in Qlik Sense.
Getting ready
For the sake of continuity, we will make use of the same script and application as in the previous recipe. We will determine the most recent position of any employee during their tenure within the organization.
Â
Â
How to do it…
- Open the
Data load editor
. Change the name of theEmployeeInt
table in the script toEmployeeIntTemp
. - Insert the following lines of code after the
EmployeeIntTemp
 tableLOAD
command. If you are copying and pasting the code in theData load editor
, make sure that the single quotes are copied in a proper format:
EmployeeInt: LOAD *, if...