IF THEN statement in Vensim

411 Views Asked by At

I would like to use these If Then statements in Vensim. Vensim does just have an if then else function. I've tried converting it, but I haven't succeeded.

Thanks for the help!

IF THEN("CO2-gehalte" >= 120, 1)
IF THEN("CO2-gehalte" < 105, 0)
2

There are 2 best solutions below

0
On

Vensim Dynamo only support for IF THEN ELSE, then what should we do? Create a nested if the solution like in excel https://support.microsoft.com/en-us/office/video-nested-if-functions-bdb0ebe2-caff-4914-835b-36796040e303

So in short :

IF THEN ELSE("CO2-gehalte" >= 120, 1,
   IF THEN ELSE("CO2-gehalte" < 105, 0, 
       -1)
)

I did this for a lot of SFD. That's the only solution for now, it's quite a programming concept, you also could see http://www.ventanasystems.co.uk/forum/viewtopic.php?t=5087. OR http://vensim.com/documentation/index.html?fn_if_then_else.htm

0
On

I often do something like this.

result = IF THEN ELSE("CO2-gehalte" >= 120, 2, 0 )

  • IF THEN("CO2-gehalte" >=105, 1 , 0)
  • IF THEN("CO2-gehalte" < 105, 0 , 0)

But I'd also suggest making the 120 and 105 constants in Vensim and give them proper units. This will make your model much easier for others to understand.