Copy values of one item to another across all matrices

6.41K viewsScriptingscripting

Hi, I am trying to achieve the following:
Copy values of “Plan” item to “Revised Plan” item (model is attached). The script should take given particular year and month and apply to this year and this months plus future months. It is easier to do it for particular matrix, but the idea is having script which goes through all matrices and if there is an item “Plan” copy it values to “Revised Plan” for a given year and months onward. It should skip matrices where those items do not exist. Any advice is appreciated.

S A U Answered question June 4, 2019

After extensive reading, learning and trying I have figured out how to write this script. If anyone interested in accessing items and categories across the whole model via script with dynamic input, please see attached model.
monthsineed = |Selector::MonthStart|.value + “..” + |Selector::MonthEnd|.value
itemineed = |Selector::Itemneeded|.value + “:”
itemdestination = |Selector::Itemwheretoput|.value + “:”
yearineed = |Selector::Yearneeded|.value + “:”
if (model.matrices[it].categories.toString().contains(“Type”))
fg = model.matrices[it].getSelection(yearineed+itemineed+monthsineed)
gh = model.matrices[it].getSelection(yearineed+itemdestination+monthsineed)
gh.values = fg.values

Tahir Answered question June 3, 2019
You are viewing 1 out of 6 answers, click here to view all answers.

Latest Questions