Use expression in window function that references columns from the current row
Is this what you are looking for ?

create table #t(id int, vars decimal(3,1), num int)
insert into #t VALUES
    (1, 0.1, 7),
    (2, 0.7, 1),
    (3, 0.3, 9),
    (4, 0.9, 5),
    (5, 0.5, 3)


;With CTE as
(
select
      t.id
     ,t.vars
     ,t.num
     ,isnull(lag(vars ,1) OVER (ORDER BY id ),0) AS vars1
     ,isnull(lag(vars ,2) OVER (ORDER BY id ),0) AS vars2
     ,isnull(lag(num ,1) OVER (ORDER BY id ),0) AS num1
     ,isnull(lag(num ,2) OVER (ORDER BY id ),0) AS num2
FROM  #t t
)

select * 
,iif(vars&lt;=0.1,vars,vars2)*num2 + 
iif(vars&lt;=vars1,vars,vars1)*num1 + 
iif(vars&lt;=vars,vars,vars)*num
from CTE

drop table #t