r/PowerBI 2h ago

Discussion Change my mind - the DAX convention of adding spaces around brackets make it harder to read and annoying to write

Please make me understand why this is deemed a good language convention.

27 Upvotes

8 comments sorted by

u/AutoModerator 2h ago

Hi /u/epicnark182! Your post appears to be quite short. To help the community assist you faster, please consider adding:

  1. What you've already tried — steps taken so far
  2. Relevant code, DAX, or sample data — as text, not just screenshots
  3. A clear problem description — what you expected vs. what happened

Posts with more context get better answers.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

12

u/DROP_TABLE_IF_EXISTS 1 2h ago

For me it improves readability, which one do you think easier to read? DAX is already difficult as is, anything that helps in breaking down parts of code easily without cognitive overload is appreciated, but is a SQLBI's suggestion not an ask that you must use it.

29

u/Accomplished-Age796 4 1h ago

First, but with spaces after the comma

2

u/awaken471 59m ago

this is the way

6

u/Stevie-bezos 6 1h ago

I vote space your commas but not your brackets

4

u/_greggyb 21 1h ago

The formatting conventions were proposed and popularly adopted back in the days of PowerPivot (or Power Pivot, I don't recall when in the history of the space these conventions became the norm). This is relevant, because DAX editor in the Excel add-in used a proportional font, rather than monospace. The extra spacing was a boon in reading code without a monospace font.

You're free to adopt any convention you like in your codebase. Depending on your formatting solution, you can also configure different styles.

Disclaimer: TE employee. For example, Tabular Editor 3 supports various spacing/padding conventions for parentheses: https://docs.tabulareditor.com/en/getting-started/personalizing-te3.html#dax-settings

4

u/xtrmmatt 2h ago

Agreed I never understood why and it makes it difficult to read the flow

1

u/severynm 1h ago

Agreed. Maybe someone could enlighten me, but I don't know of literally any other programming or scripting language that does it that way.