Last week, at the SQL Server Days conference in Belgium, Kasper mentioned in his presentation that it was possible to define variables inside variables in DAX. So, for example, you could define a measure like so:
1234567MyMeasure =var Outer1 =var Inner1 = 1var Inner2 = 2return Inner1 + Inner2var Outer2 = 3return Outer1 + Outer2
This measure returns 6 as you might expect:
There aren’t any performance benefits to doing this, although of course it helps with code readability and organisation (thanks to Marius for confirming this).
With my newly rekindled love of DAX I thought this was quite interesting. I’m not really sure why though, given that it’s not particularly useful; I think Matt might be right: