Page 1 of 1
GET DIRECT LOOKUPS with subscript
Posted: Mon Feb 21, 2022 9:52 am
by EwoutH
I want to use subscripted lookup and tried using
GET DIRECT LOOKUPS, but didn't manage to get it to work.
Basically I have a table in a CSV with years (time) on the horizontal axis and different age groups (which I want subscripted) on the Y-axis. I load in subscript values into a variable
age_group using:
Code: Select all
GET DIRECT SUBSCRIPT('data/population_data.csv', ',', 'A2', 'A20', '')
I tried using
GET DIRECT DATA with the subscript in
population-pyramid-submodel-2.mdl, which doesn't load the data correctly over time. So I tried using
GET DIRECT LOOKUPS subscripted, but that crashed and after that the model (
population-pyramid-submodel-2.mdl) doesn't even open again.
So is it possible to load in lookup data subscripted? If not, what would be a work around? If so, how do you do it? If with
GET DIRECT LOOKUPS, could a subscripted example model be added?
The models are attached below. The forum doesn't support attaching CSV files, the
population_data.csv can be downloaded here:
https://we.tl/t-ixFcuFTJkC
- GET DIRECT DATA with subscript, that doesn't load the table:
- GET DIRECT LOOKUPS with subscript, that doesn't open:

- Screenshot_707.png (85.84 KiB) Viewed 21680 times
Re: GET DIRECT LOOKUPS with subscript
Posted: Mon Feb 21, 2022 11:37 am
by EwoutH
I managed to fix it and use a GET DIRECT LOOKUPS with a subscript!
Could maybe an example model be added to the
GET DIRECT LOOKUPS documentation? Since I believe it's non-trivial since you also have to define the subscript range with GET DIRECT SUBSCRIPT.
Fixed model:
Re: GET DIRECT LOOKUPS with subscript
Posted: Mon Feb 21, 2022 1:20 pm
by Administrator
EwoutH wrote: ↑Mon Feb 21, 2022 9:52 amI tried using
GET DIRECT DATA with the subscript in
population-pyramid-submodel-2.mdl, which doesn't load the data correctly over time.
What errors did you get when trying to load the data?
Re: GET DIRECT LOOKUPS with subscript
Posted: Mon Feb 21, 2022 3:44 pm
by tomfid
The example models in the Help system should work in exactly the same way if you change XLS to DIRECT and resave the xlsx as csv.
Re: GET DIRECT LOOKUPS with subscript
Posted: Tue Feb 22, 2022 4:09 pm
by EwoutH
Administrator wrote: ↑Mon Feb 21, 2022 1:20 pm
What errors did you get when trying to load the data?
It just did a hard crash when I tried to open the 2b model. No idea why. Is there some way to get debug output?
tomfid wrote: ↑Mon Feb 21, 2022 3:44 pm
The example models in the Help system should work in exactly the same way if you change XLS to DIRECT and resave the xlsx as csv.
A great to know! Maybe that can be mentioned in the docs itself?
Re: GET DIRECT LOOKUPS with subscript
Posted: Tue Feb 22, 2022 9:44 pm
by tomfid
9.2 will have a crash reporter.
population_data.csv can be downloaded here
You can always zip an archive of model + supporting files.
Re: GET DIRECT LOOKUPS with subscript
Posted: Tue Feb 22, 2022 9:50 pm
by tomfid
For the '2' version of the model, there are two issues:
- time axis of the model doesn't match the data
- function call is wrong: time is in row '1' not '2'
Re: GET DIRECT LOOKUPS with subscript
Posted: Tue Feb 22, 2022 9:55 pm
by tomfid
2b works fine for me, after fixing the same issues. I'm currently running 9.2 though.
Re: GET DIRECT LOOKUPS with subscript
Posted: Thu Feb 24, 2022 10:21 am
by EwoutH
tomfid wrote: ↑Tue Feb 22, 2022 9:55 pm
2b works fine for me, after fixing the same issues. I'm currently running 9.2 though.
Thanks for testing! Can you test if the
population-submodel.mdl in the ZIP below works on your system with both Vensim 9.1.1 and 9.2? It now also crashes on opening on both a Windows and a macOS system, both using Vensim 9.1.1. Am I doing something wrong with reading the data?
A crash report would be very useful!
Re: GET DIRECT LOOKUPS with subscript
Posted: Thu Feb 24, 2022 9:31 pm
by tomfid
This doesn't crash in 9.2, but doesn't run either. When I look at it with a text editor, I see:
Code: Select all
{UTF-8}
age group : GET DIRECT SUBSCRIPT ,'', 'A21', 'A2', ',', 'data/population_data.csv', 'data/population_data.csv'\
,
',',
'A2',
'A21',
''
~ People
~ |
The function's parentheses are missing, and it seems like there are too many arguments.
Re: GET DIRECT LOOKUPS with subscript
Posted: Thu Feb 24, 2022 9:40 pm
by tomfid
When I correct that to
Code: Select all
age group : GET DIRECT SUBSCRIPT( 'data/population_data.csv',
',',
'A2',
'A21',
'')
~ People
~ |
It works in 9.2.
Bug with verbose saving of GET DIRECT LOOKUPS
Posted: Mon Feb 28, 2022 9:11 am
by EwoutH
tomfid wrote: ↑Thu Feb 24, 2022 9:40 pm
When I correct that to
Code: Select all
age group : GET DIRECT SUBSCRIPT( 'data/population_data.csv',
',',
'A2',
'A21',
'')
~ People
~ |
It works in 9.2.
Thanks a lot, I adjusted the .mdl file manually, and that fixes the issue!
I think I also found the cause. We use the Verbose Equation-format to have readable diffs with Git. But apparently, the verbose saving doesn't correctly format the equation.
I have attached the manually fixed (correct) model and the verbose saved (incorrect) models below.
Re: GET DIRECT LOOKUPS with subscript
Posted: Mon Feb 28, 2022 5:47 pm
by tomfid
Nice work. I'll put in a ticket to fix this. There's also a problem with reform/clean alphabetizing, so it may take a little while to rewrite the whole subsystem.
In the meantime, there are some new settings in 9.2 that may be of interest. See Model>Settings>File Format. You can move volatile settings (some of the stuff after :L <%^E!@) into a separate sidecar file to avoid false positive diffs. You can also switch to new storage for the sketch (via the >9.2 option) that avoids most spurious moves, even when using a model at multiple resolutions and scales.
Re: GET DIRECT LOOKUPS with subscript
Posted: Mon Mar 07, 2022 10:23 am
by EwoutH
tomfid wrote: ↑Mon Feb 28, 2022 5:47 pm
Nice work. I'll put in a ticket to fix this. There's also a problem with reform/clean alphabetizing, so it may take a little while to rewrite the whole subsystem.
Thanks for putting in the ticket, do you have any update on it? It still persists in 9.2.0.
Re: GET DIRECT LOOKUPS with subscript
Posted: Fri Mar 11, 2022 6:05 pm
by tomfid
It came to late in the release cycle to make the cut. I don't have a target date for a fix, because this is potentially complex. For the moment, the workaround is to avoid the Verbose setting, and use As Entered. Unfortunately this may cause at least a one-time large diff.
Re: GET DIRECT LOOKUPS with subscript
Posted: Wed Mar 23, 2022 1:27 pm
by EwoutH
Thanks for getting back to me Tom. It looks for me on the surface like a relatively simple parsing issue, is it more complex than that?
Re: GET DIRECT LOOKUPS with subscript
Posted: Thu Mar 24, 2022 4:25 pm
by tomfid
Short answer, yes.