Created
June 29, 2022 14:57
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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