Reading in time series or constants

Use this forum to post Vensim related questions.
Post Reply
MarvinK
Junior Member
Posts: 15
Joined: Wed Nov 24, 2021 4:17 pm
Vensim version: DSS

Reading in time series or constants

Post by MarvinK »

Hello everyone,

I am looking for an elegant way to use a slider in a very extensive model to decide whether time series (“GET XLS DATA...”) or only constant (average) values (“GET XLS CONSTANTS...”) should be read in from the same EXCEL file. I thought this would be very helpful for calibration, testing, and analyses.

My spontaneous idea was to use an IF THEN ELSE function to check whether a slider or the variable behind it has the value 0 or 1. However, the “GET...” functions “cannot include other expressions”.

I could define two more constants for each parameter, in each of which a time series or a constant value is read in. I could then use an IF THEN ELSE function in the actual parameter. If I do the whole thing via shadow variables, the diagram would also remain clear. However, the model consists of several sub-models with quite a few parameters. The effort would therefore be very, very high.

Does anyone have another solution? I would appreciate any tips!

Best wishes from Germany,
Marvin
tomfid
Administrator
Posts: 3986
Joined: Wed May 24, 2006 4:54 am

Re: Reading in time series or constants

Post by tomfid »

This won't work due to different variable types. However, you could read both and put the IF statement downstream, like:
x = GET XLS CONSTANTS(...)
y = GET XLS DATA(...)
x or y = IF THEN ELSE( slider, x, y )
MarvinK
Junior Member
Posts: 15
Joined: Wed Nov 24, 2021 4:17 pm
Vensim version: DSS

Re: Reading in time series or constants

Post by MarvinK »

Thank you for your feedback.

Does that pick up on what I had outlined? So, are you suggesting creating variables “x” and “y” and then using an IF THEN ELSE function in the parameter itself?
tomfid
Administrator
Posts: 3986
Joined: Wed May 24, 2006 4:54 am

Re: Reading in time series or constants

Post by tomfid »

Correct.

The effort shouldn't be too much. One possible trick would be to implement this via copy-paste in the text editor.

For example, if you currently have

paramX = 123

you can replace it with the pattern I suggested above

x = GET XLS CONSTANTS(...) ~ unit ~ doc |
y = GET XLS DATA(...) ~ unit ~ doc |
paramX = IF THEN ELSE( slider, x, y ) ~ unit ~ doc |
Post Reply