Hi folks, I came across an unusual syntax for passing filters to a measure differently in DAX and want to share that with you.
Let’s start with following basic measure:
SUM ( FactRevenue[Rev.] )
Using this measure, you could calculate a YTD value by passing the DATESYTD() function to the CALCULATE function like this:
CALCULATE ( [Revenue]; DATESYTD ( DimCalendar[Date] ) )
But there is another syntax you can use:
[Revenue](DATESYTD ( DimCalendar[Date] ) )
This version looks like no CALCULATE is needed, but CALCULATE always is added to a measure call. For this reason the conventional and the unconventional version internally are the same thing.
All my code above was formatted using daxformatter.com. When I tried to format the unconventional version, it automatically got converted into the conventional version. So I had to format it manually. For this reason I am pretty sure, Marco and Alberto have good reason not to use this kind of syntax. Anyway: I found it interesting that it works and wanted to share this observation with you 🙂
Regards from Germany,
I write my posts for you, the reader. Please take a minute to help me write my posts as well as possible. Thank you 🙂
|Post provides benefit||1|
|Post is understandable||1|
|Appropriate post length||1|