# DataLink – Order of Execution

I’d be curious to know how Quantrix figures the order in which to execute DataLinks.

I have an external datalink that feeds a reference matrix; then another matrix uses lookup formulas to pull data from the reference matrix; then another datalink copies the calculated values to an export matrix.

You can see that in this case the order of datalinks is important; the import first should come first, then the export.

Excellent… this is just the sort of technical information I need to design the model properly. I think I can avoid the situation you refer to by allowing only two levels of datalink, one for import, one for exporting the final answer to the export views.

That said, the ability to reorder datalink execution would be a great feature… I envision a form that shows a list of all the model’s datalinks, with each showing the source and destination matrices; you’d have the ability to move the datalinks up or down in the list to change the execution order. You could also do something graphical like the formula Dependency Inspector, only for datalinks.

Quantrix calculates the “depth” of the link to determine the order. The “shallowest” links are updated first. Links with the same depth are not guaranteed any particular update order. Links which refer to external sources (e.g. JDBC, CSV, XML) have a depth of 0. Internal links (matrix links) have a depth of 1 + the depth of the link (if any) the source matrix has.

In your case, this algorithm should work. However, if you had a situation where (for instance):

– matrix b was datalinked to matrix a

– matrix c calculated off of matrix b

– matrix d is datalinked to matrix c

you wouldn’t be guaranteed the right update order because both matrix D and matrix B have a depth of 1

In other words, the calculation step breaks the “dependency tree” of the datalinks.

Please feel free to post further questions.

Cheers,

pete