Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save data-goblin/a0d5d93ecf1e6927de08084c194dcaf6 to your computer and use it in GitHub Desktop.
Save data-goblin/a0d5d93ecf1e6927de08084c194dcaf6 to your computer and use it in GitHub Desktop.
A Tabular Editor C# script to get all measures in a model as a mermaid diagram syntax.
string dependancies = "flowchart LR\n%% Measure dependancy mermaid flowchart";
foreach(var _measures in Model.AllMeasures )
{
var _upstream = _measures.DependsOn;
var _upstream_measures = _upstream.Measures.OfType<Measure>().Select(c => c).Distinct();
dependancies += string.Format("\r\n\n%% [{1}] Dependancies:\n\t{0}[\"{1}\"]",
// 0 - Lineage tag of the measure in scope
_measures.LineageTag,
// 1 - Name of the measure in scope
_measures.Name);
foreach( var measure_dependencies in _upstream_measures )
{
dependancies += string.Format("\r\n\t{2}[\"{3}\"] --> {0}[\"{1}\"]",
// 0 - Lineage tag of the measure in scope
_measures.LineageTag,
// 1 - Name of the measure in scope
_measures.Name,
// 2 - Lineage tag of the dependant measure
measure_dependencies.LineageTag,
// 3 - Name of the dependant measure
measure_dependencies.Name);
}
}
dependancies.Output();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment