However, what the engine does is not necessarily what the semantic of the query might lead us to think, as long as the result is the same. Which is better? At first sight, you might think that the VALUES version is faster than the KEEPFILTERS one, because the number of elements iterated is potentially smaller. We have seen three different syntaxes for OnlyRed producing the same result. Internally, this corresponds to the following FILTER: The same result for the OnlyRed_Values measure is possible using the KEEPFILTERS syntax, as in the OnlyRed measure: In the AlwaysRed measure, the filter over the Color column replaces the color in the row, whereas in the OnlyRed_Values measure the filter over the Color column intersects the filter of the color in the row. The difference between the two functions is clearly visible in the following example. If you do not want to lose the existing filter, a widespread technique – used extensively in our previous books – is to replace ALL with VALUES, as in the following example: The semantic of the filter removes any existing filter applied to the same column, replacing it with the new filter defined in the predicate condition. Internally, the filter expression is transformed into a FILTER, as described here: When you use a predicate, it is internally transformed into a corresponding FILTER statement. The syntax you use in CALCULATE to apply a filter is always a table. In a way, this article is a way of making up for not having included a better description of KEEPFILTERS in our book. However, KEEPFILTERS’ relevance is quite a bit wider. If you read our book The Definitive Guide to DAX, you might consider KEEPFILTERS as only necessary when you have arbitrarily shaped filters that you do not want to lose by applying additional filters on individual columns. There is an additional disclaimer to this article – if you think that it is too complex, just skip to the next paragraph, but if you think you already know KEEPFILTERS, please read this. UPDATE : Read the new article that includes a video: Using KEEPFILTERS in DAX.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |