In the latest weeks I received several requests to support a different color for variable names in DAX Formatter, just as the formula editor available in Power BI.

I finally implemented a solution that I consider a workaround, because of some limitations that are not visible now. In fact, a variable cannot have the name of a table in the data model. You might think this is a good idea, but it is not – and in fact this will likely change in the future.

Think about this: you have a working model with many measures, you import a new table and… all of a sudden, you break some existing measures because a variable used there have the same name of an imported table. We might expect that in the future a variable name will override an existing table name – this way, an existing model will not be broken by just adding a new table. However, this will raise another issue, which is the possible confusion when you use a column reference using a table name that is the same name of a variable name assigned to something else. But this is not what you can do today, so don’t worry: just format your DAX code on www.daxformatter.com and enjoy the new color for variables’ names!