How to create increasing variable as another one decreases

Hi Everyone,

I have 2 variables that I need to create dynamic selectors with.

While varyear = 2021 , varparentid is 957
varyear = 2020 , varparentid is 958
varyear = 2019 , varparentid is 959
varyear = 2018 , varparentid is 960

How do I create varparentid correlated with varyear?

Thanks in advance.

Unless I have misunderstood, are your initial values fixed? 2021 and 957?

If yes then
Parentid = parentid+datediff(2021-varyear)

If a counter starts counting down from 2021 by one year, this may work like so:

first year datediff is zero in 2021
Parentid = 957
When varyear is 2020
Parentid = 957+(2021-2020)
When year is 2019
Parentid = 957+(2021-2019)
When year is 2018
Parentid = 957+(2021-2018)

and so on

1 Like

There are no initial values, they both should be dynamic

varparentid = 957 + (2021 - varyear)

This one works
You gave me a great hint. Thanks!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.