Grouping of items

7.81K viewsScripting
0

I just started to have a closer look into the scripting capabilities of QM. First of all is there an example how to create a structure with grouped items?

I refer to the “”Setting up a model”” example -> Create a Structure -> line 14:
salesProjectionsMatrix.categories.create(“”Product””, [“”Widget””, “”Gadget””, “”Gizmo””, “”Total””])

How should the line look if I want to group “”Gadget”” and “”Gizmos”” into “”Group””?

I know the functionality is there but without a good documentation/programming guide and a broad basis of examples Quantrix runs into the old problem that it is technically advanced but no one understands or sees the benefits unless she/he is willing to invest tons of hours into QM.

Thanks
Ody

0

Ody,

Here is a possible solution I have found so far for your question:

[code:1z9qolzg]
[color=green]// Create a matrix object of the target matrix first [/color]
Matrix salesProjectionsMatrix = |’Sales Projections’|

[color=green]// Group the items [/color]
salesProjectionsMatrix.getSelection(“Gadget..Gizmo”).group()

[color=green]// Rename the created group by addressing the category and [/color]
[color=green]// the first item in the group by name [/color]
salesProjectionsMatrix.categories[”Product”].items[”Quantity”].parent.name = “Cool stuff”

[color=green]// OR [/color]

[color=green]// Rename the created group by addressing the category and [/color]
[color=green]// the first item in the group by index numbers[/color]
salesProjectionsMatrix.categories[1].items[1].parent.name = “Cool stuff”
[/code:1z9qolzg]

I am sure there are other and even simpler and more Groovy stylish solutions.

Best,
Dominik

You are viewing 1 out of 12 answers, click here to view all answers.