The computeRelative node is useful to traverse across rows to identify something or calculate something.
Three important items in a computeRelative node:
- Partition By
- Order By
- Sort Direction (for 2 - Order By)
From the above screenshot:
- It is Opportunity
- Partition By Account Id
- Order by CreatedDate and sort by Descending
The result in the calculated fields:
- the first record in the partition would be the Last Opportunity created for an Account
- the last record in the partition would be the First Opportunity created for an Account
This is because we order by Descending.
There is two Expression Type in the calculated field for computeRelative:
2. Source Field
Use Case: to identify the First or Last or Previous record
SAQL Expression = case when previous(Id) is null then "Yes" else "No" end
* Id in above SAQL can be any field (always with value), as it is just used to check if any previous record exists.
using Source Field
Based on my testing, using Source Field is faster than SAQL in the dataflow. In the below example, the dataflow processing close to 1.6 million rows