How do I complete this SQL code in Alteryx with the formula tool without directly selecting from the table?

73 views Asked by At
SELECT 
    *, 
    LAG(orderdate, 1, NULL) OVER (PARTITION BY fullaccountnum, cin ORDER BY orderdate) AS previous_orderdate 
FROM 
    table.revenue_invoice_data

I've tried the expression below in the formula tool to no avail. I keep getting the error: syntax or semantic error analysis.

fullaccountnum == [fullaccountnum-1] && 
cin == [cin-1] ? [orderdate-1] : Null()
2

There are 2 answers

0
Madhukar On

Use the Multi-Row Formula tool to get equivalent of LAG function. If the column name is col1, then the equivalent expression to be used in the Multi-Row Formula to access previous row's data is [Row-1:col1]

0
leaflion On

The regular Formula tool can not be used across multiple rows. You'll have to use the Multi-Row Formula tool.