Power BI supports extensive Data Analysis Expressions(DAX) scripting to achieve complex business scenarios. It is a good practice to maintain a document for each report which helps in future development. The Document can include screenshots of Report Pages, Purpose of the Report, Lists of Navigation, Tables and Queries and a complete listing of the DAX formulas.
All this information is easily achievable except for the DAX formulas. Using DAX users can create Measures and Columns in PowerBI. However, there is no direct option to export the DAX formulas for documentation purposes. This blog will cover exporting the Measure and Column definitions into a CSV file from Power BI.
Steps to export the DAX formulas
1. Navigate to Model View.
2. Click File Menu -> Export as Power BI Template.
3. Exported PowerBI template will have the extension .pbit. Open the PowerBI template file as RAR file.
4. List of files in PowerBI template.
5. Click and Open DataModelSchema in any JSON editor.There are plenty of JSON editor available online. You can access the below link to use the same JSONeditor used here in this blog.
6. Generally, JSON is represented as a Key Value Pair. You can Navigate to the Key Value Pair of tables which will list all the tables used in the PowerBI report.
E.g.: In the below highlighted section we use the Key as tables and Value within the set bracket
7. For each key value pairs inside tables key have following structure. Columns and Measures created in PowerBI will have separate key value pair. Here we have just highlighted the Measure Key Value Pair.
8. After expanding the Measure key, we can get the value of each Measures. Here the value as DAX formula.
9. Copy the value of the Key Measure.
10. Paste the copied Value of the Key Measure in any of the JSON to CSV editor. You can refer this website to learn more. https://json-csv.com/
11. CSV File will have the following structure. This is the based Value of the Key Measure. It may differ for the Key Value Pair of Column.
By this we have achieved exporting Measure and Column formulas from Power BI to a CSV File.
Know more about Microsoft Power BI services offerings from Visual BI solutions here.