Skip to content

Instantly share code, notes, and snippets.

@bjulius
Created August 12, 2023 13:51
Show Gist options
  • Save bjulius/f7fdfd9e5a3e6beee20d5608c4ea1a30 to your computer and use it in GitHub Desktop.
Save bjulius/f7fdfd9e5a3e6beee20d5608c4ea1a30 to your computer and use it in GitHub Desktop.
C# Tabular Editor Script to Export All DAX Measures to Text File
// C# Tabular Editor Script to Export All DAX Measures to Text File
// Thanks to Pavel Adam for this code
var vDT = DateTime.UtcNow ;
string sDateTime = vDT.ToString() ;
string sTargetDir = "C:\\Temp\\";
string sFilename = vDT.ToString("yyyy-mm-dd HH-mm-ss") ;
string newLine = "\r\n";
string measureSeparator = "=========";
string result = "" + measureSeparator + newLine + sDateTime + newLine + measureSeparator + newLine;
foreach(Table t in Model.Tables){
foreach(Measure m in t.Measures){
result = result + measureSeparator + newLine + t.DaxObjectName + " " + m.DaxObjectName + "=" + newLine;
result = result + m.Expression + newLine + newLine;
}
}
SaveFile(sTargetDir + "AllMeasures" + sFilename + ".txt", result.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment