DAX移除过滤器vs全部 [英] DAX REMOVEFILTERS vs ALL
问题描述
如何用以下代码替换 REMOVEFILTERS 老式功能代替ALL和VALUES?此练习只是为了更好地了解REMOVEFILTERS。
How to substitute REMOVEFILTERS in the following code with old school functions ALL and VALUES instead? This exercise is just to better understand REMOVEFILTERS.
CALCULATETABLE (
-- get all products, in the modified filter context of...
VALUES ( MyTable[product] ),
-- no filter on product
REMOVEFILTERS ( MyTable[product] ),
-- and under the same parent category
VALUES ( MyTable[Category] )
)
据我所读的提示,此处是可能的。
As far as I can read the hints here that could be possible.
以下示例数据:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcisqzSwpVtJRSiwoyEkF0oZKsTpIwkmJeUAIZJigipfn56QlpRYVVQLZpqhSyRlQcWOweFhqempJYlJOKlgusagovwTIMMKUK8gvSSzJhzsBRS4/LzM/D0ibo1qFw9HILogFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Category = _t, Product = _t, Amount = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Amount", Int64.Type}})
in
#"Changed Type"
推荐答案
REMOVEFILTERS只是ALL的别名,因此它的工作原理相同。
REMOVEFILTERS is just an alias of ALL here, so it works just the same.
基本上,ALL返回一个包含所有行的表,而忽略任何可能
Basically, ALL returns a table including all rows, ignoring any filters that might have been applied.
但是,当ALL用作CALCULATE或CALCULATETABLE的过滤器参数时,其行为完全不同:它将删除表中的过滤器并执行n
However, when ALL is used as a filter argument of CALCULATE or CALCULATETABLE, it behave totally differently: it removes filters from the table and does not return a table.
为了缓解ALL的这种混乱行为,引入了REMOVEFILTERS来代替在CALCULATE中使用ALL时。
To alleviate this confusing behavior of ALL, REMOVEFILTERS was introduced to replace ALL when it is used inside CALCULATE.
有关更多详细信息,请参阅本文。
https:/ /www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/
For more details, you may look at this article. https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/
这篇关于DAX移除过滤器vs全部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!