![]() One of the newest external tools, Bravo, also allows you to format your code, and you can also format all your DAX measures at once! See Tabular Editor documentation for more details: Useful script snippets | Tabular Editor Documentation. While you can format individual formulas, you can run an advanced script in Tabular Editor to format all your measures. In Tabular Editor (2 and 3) you can also format code by using the same DAX Formatter button, and the keyboard shortcut is also F6: The keyboard shortcut is F6:Īgain, this is good when you only need to format one formula you’re working on. In DAX Studio, there’s a button to format your query, and it works for individual formulas too. DAX Formatter is good when you need to format one formula at a time. You can then copy by selecting the Copy button, then paste your formula back to Power BI. You’ve got the option to change some settings too, like spacing and separators. It’s a web-based tool, and it’s very easy to use - you just paste your formula and select Format. DAX Formatterīefore I got into the habit of formatting my formulas myself, I used DAX Formatter a lot. you can read my other blog post: DAX formula bar keyboard shortcuts in Power BI Desktop. If you’d like to know which key combinations you can use to add/reduce indendation, comment, add line breaks, etc. The most important thing about it is to be consistent. If you’re disciplined enough, you can format your formulas yourself, which requires no tools at all. How can you format you code? Your own formatting There really was a mistake, which was hard do spot, because the formula was so difficult to read! The formula above is a real formula written by someone else - I only changed table and column names, and I kept the rest as is. Once you format the formula, you’ll see other issues immediately, one of them being that most constructs aren’t needed, and there’s a mistake in the formula. In its current state, it’s difficult to read the formula. Despite there being several ways to format your DAX code, I still see a lot of formulas that aren’t formatted.įor example, can you tell what this formula is doing?Įxample bad = CALCULATE(SUM(Sales), FILTER(Sales, True = (CONTAINS(VALUES('Item'), 'Item', "Full") & COUNTROWS(VALUES('Item')) = 1))) + CALCULATE(SUM(Sales), FILTER(Sales,True = (CONTAINS(VALUES('Item'), 'Item', "Discounted") & COUNTROWS(VALUES('Item')) = 1))) While unformatted DAX formulas may not affect the calculation speed, they can take a lot of time to read, and they can even hide errors just because the errors are hard to spot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |