Calculations derived from Element Properties

Started by almathomas, June 07, 2023, 21:28:21 PM

Previous topic - Next topic

almathomas

Good afternoon,

I'm going to apologize for my ignorance. I have just started looking into this tool. I love the ability to add properties to the elements in the model.

With the label expressions or the JArchi plug-in would it be possible to create calculations?

1. First on an element level. If I have multiple properties like Maintenance Cost, Renewal Cost, etc, could I create a label expression to show on the element total cost.

2. If I were to populate cost property for all the elements in a diagram for example. Show that diagram in a Framework View, could I use a label expression to calculate cost of all the elements associated with that diagram in the Framework View.

This would provide a holistic view of the Enterprise Architecture and associated spend in the targeted view.

Thank you,
I do appreciate your work. I'm just learning what this can do.

Jean-Baptiste Sarrodie

Hi,

You can't do this with label expressions (expressions are only meant to show existing information, they can't do math operations).

But that's possible with jArchi. This requires a script that would compute such sums and then store them into properties or visual notes. Of course this won't be dynamic, so you would have to run the same script each time the model is updated.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

andycallo

Quote from: Jean-Baptiste Sarrodie on June 07, 2023, 22:25:50 PMBut that's possible with jArchi. This requires a script that would compute such sums and then store them into properties or visual notes.

Do you know which JArchi script would do this? Sorry like the OP I am new to all of this and now sure where to look for this type of thing (have searched the forum and this came up as the best option)

Phil Beauvoir

#3
Quote from: andycallo on December 15, 2024, 19:45:36 PMDo you know which JArchi script would do this? Sorry like the OP I am new to all of this and now sure where to look for this type of thing (have searched the forum and this came up as the best option)

Hi,

basically the idea would be to search for a specific property in the model by name and sum the values. Something like this:

// Initialise total
total = 0;

// Iterate through all elements in the selected model
$("element").forEach(element => {
    // Get the value of each property that has a name of "cost"
    value = element.prop("cost");
    // If there is a value and it's a number add it to the total
    if(!isNaN(Number(value))) {
        total += Number(value);
    }
});

// Add the total to the first selected element as a property
selection.first().prop("total", total.toString());


There might be a better way to do this - if so, over to you jArchi experts...
If you value and use Archi, please consider making a donation.
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.