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:
1. SAQL
2. Source Field
Use Case: to identify the First or Last or Previous record
using SAQL
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
In this method, the new calculated field will contain "Yes" if that's the first row, the rest will be the Id from the previous record, which is not important.Comparison
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
No comments:
Post a Comment