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:
Revenue =
SUM ( FactRevenue[Rev.] )
Using this measure, you could calculate a YTD value by passing the DATESYTD() function to the CALCULATE function like this:
RevenueYTD_conventional =
CALCULATE ( [Revenue]; DATESYTD ( DimCalendar[Date] ) )
But there is another syntax you can use:
RevenueYTD_unconventional =
[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,
Lars
I write my posts for you, the reader. Please take a minute to help me write my posts as well as possible. Thank you 🙂
[yasr_visitor_multiset setid=2]
Sie müssen den Inhalt von reCAPTCHA laden, um das Formular abzuschicken. Bitte beachten Sie, dass dabei Daten mit Drittanbietern ausgetauscht werden.
Mehr InformationenLars ist Berater, Entwickler und Trainer für Microsoft Power BI. Er ist zertifizierter Power BI-Experte und Microsoft Trainer. Für sein Engagement in der internationalen Community wurde Lars seit 2017 jährlich durch Microsoft der MVP-Award verliehen. Lies hier mehr…
Neueste Kommentare