Forum Discussion
Help with FILTER: "multiple columns" error
Ah, I see what you're going for. Since you can make base measures that can be referenced and filtered in other measures, you want to be able to have a premade filter declaration that you could plug in the same way. Unfortunately that's not possible. Measures aggregate to a single scalar value. What you're proposing would have to return a table, so measure-like filter declarations would have to be a completely different type of data from measures, and that currently doesn't exist.
The closest we have is the New Table button, which allows you to define naked tables in DAX. The formulas look like what you've written. You can't really use them in the plug-and-play method you're imagining though, and the tables exist in memory even if there's no other measure referencing them at the time, so it's not really a substitute for what you want.
I actually proposed the same idea to some developers at the Data Insights Summit last year. I might submit it to the idea forum to see what the community thinks.
Note, that for the example you provided, you could just add a column called PreviousYTD defined as:
PreviousYTD= YearMonth[Year]=YEAR(TODAY())-1 && YearMonth[month]<=MONTH(TODAY())
This is just a regular boolean expression, you could use as:
Previous YTD Sales = CALCULATE([Sales]; YearMonth[PreviousYTD] )
This would work, since in your case the definition of the previous year is not dynamic (at least not depending on the user's selection).
(Usually, when people talk about about Previous year calculations, it means "one year before the currently selected date").