Created
August 12, 2023 13:51
-
-
Save bjulius/f7fdfd9e5a3e6beee20d5608c4ea1a30 to your computer and use it in GitHub Desktop.
C# Tabular Editor Script to Export All DAX Measures to Text File
This file contains hidden or 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
// 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