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.
Thank you again, KHorseman.
I think it would be useful if we could hace a way of storing expressions for future use which don't actually compute until used in a proper context. Even a notepad type of functionality might do...
As it is¡ I have started a document with "most frequently used" expressions and just copy and paste...
Something else I wish I could do is classify measures into categories regardless of tables; It would really make life much simpler...
Thanks again!
Paul
- Anonymous9 years agoNot applicable
Well there is good news on the last bit. You can use Enter Data to create a dummy table with nothing in it, then attach measures to that table. Measures can go anywhere. So just make tables for each category you want. The measure tables will all be stuck with one empty column and I don't think there's anything you can do about that, but it's only mildly ugly.
I like your expression scratchpad idea. You might want to submit that.
- PaulDBrown9 years ago
Community Champion
Anonymous
I think the scratchpad idea is a bit clumsy for what I'm trying to do, but might add more value for other things....
What I think is worth exploring is the idea of being able to include expressions as part of the selectable objects. IE. we have Tables, Columns, Measures...why not include Frequently used expressions (FUSEX so to speak...)?
Imagine you had an expression you had to use frequently. In my case, I'm building a model where the most relevant information is Current month and Current Year results compared to the same periods in the previous years, aswell as including flexibility to be able to select time periods even within the same page in a report (which means you cannot use a slicer and filtering by visual is impossible (?) if the report will be uptdating day by day, month by month etc...Added to all this, you have a high granulartiy sales data table, but your Budget and estimates tables are on a monthly basis, which involves setting up a period table and renders Time Intelligence functions meaningless when comparing values from high and low granularity...
So it comes down to how do you establish the current month and year (+ period comparisons)? As far as I have been able to workk out, you have to filter tables manually in CALCULATE functions, or add calculated columns (which as far as I have read in a couple of books you should avoid if no other alternative is possible: ie a measure cannot be computed.
So what I have been doing in this model is computing a filter within a CALCULATE function to define the time period I need to establish, such as:
FILTER(YearMonth;
YearMonth[year]=YEAR(TODAY())
&&
YearMonth[Month]=MONTH)TODAY())Where YearMonth is the period table which has a relationship with the 'sale's, 'budget' and 'estimates' tables.
Now since i use these kinfd of expressions constantly, I have resorted to typing them in a word document and copy/pasting them. Which is fine, it saves time, But in a team work environment it is not efficient.
So my suggestion is to enable Power BI to "store" expressions as another selectable item, just as we have Tables, Columns, Measures...
The idea being that we could write expressions (FUSEX) such as:
Current Month Expression=
FILTER(YearMonth;
YearMonth[year]=YEAR(TODAY())
&&
YearMonth[Month]=MONTH)TODAY())and use a suitable wrapper such as {.....}
These expressiones would then be stored and available in the field menu (or a new expressions menu) and could be computed in the form of:
[Total Sales Current Month] = CALCULATE(SUM('Sales'[Sales]);
{Current Month Expression}Et voilà...
Does that sound preposterous?
- Anonymous9 years agoNot applicable
PaulDBrownnot preposterous at all. That's exactly the sort of thing I was envisioning: reusable measure-ready table/filter definitions. ReMReTFiDs.
...
That is not a better name than FUSEX. :P
Write up a clear description and post it to the Ideas forum. Maybe we can drum up enough votes to get it noticed.