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

Hello Ody,

It seems that it is not possible to group a single item with the mentioned code snippets so far. But I have found a workaround:

[code:2y0m7rh6]
[color=green]// Create the matrix object[/color]
def Matrix matrix6 = |Matrix6|

[color=green]// Add a dummy item below the item to be grouped[/color]
matrix6.categories[1].children.create(1).get(0).name = “dummy”

[color=green]// Create the group including the dummy item[/color]
matrix6.getSelection(“Sales..dummy”).group()

[color=green]// Delete the dummy item[/color]
matrix6.categories[1].items[”dummy”].delete()

[color=green]// Rename the group item[/color]
matrix6.categories[1].items[0].parent.name = “Group Single”
[/code:2y0m7rh6]

You can use this code in the attached model with Matrix6.

Ben, do you have another trick to achieve this?

Best,
Dominik

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