Copy values of one item to another across all matrices

Generic selectors
Exact matches only
Search title only
Search in content
Search in all posts
Search in pages
Answers
Questions
896 viewsScriptingscripting
0

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.

Answered question
0

Hi Tahir.
Thank you for sharing the a-script. It was informative. I have optimized a little bit a-script:

Answered question
1

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.
0.upto(matrices.size-1)
{
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
}
}

Answered question
0

This model is an example. Real models are bigger. Data source for Plan is manual entry.

Answered question
0

In the attached model there are 5 matrices in total. Manually filling their cells would not take a long time … Another question: what is the data source for the ‘Plan’ Item for each of the three matrices sharing category A?

Answered question
0

Hi SAU. I meant from May 2019 until the end of the year. There are many matrices and many model templates where this operations is required. Those are all assumptions which should be simply populated again. Manually it would take a long time. Exactly I would like to copy “Plan”  item values from May 2019 to Dec 2019 and paste to “Revised Plan” item values May 2019 to Dec 2019 in all matrices with one script.

Answered question
0

Hi, for May 2019 manually fill in the cells of all matrices instead of the script: what exactly do you want to get in the model?

Answered question

Latest Questions