DAX 删除过滤器与所有过滤器

Prz*_*min 4 dax powerbi

如何用老式函数 ALL 和 VALUES 替换以下代码中的REMOVEFILTERS ?这个练习只是为了更好地理解 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] )
)
Run Code Online (Sandbox Code Playgroud)

据我所知,这里的提示是可能的。

这是示例数据:

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"
Run Code Online (Sandbox Code Playgroud)

Kos*_*kai 8

REMOVEFILTERS 只是 ALL 的别名,所以它的工作原理是一样的。

基本上,ALL 返回一个包含所有行的表,忽略可能已应用的任何过滤器。

但是,当 ALL 用作 CALCULATE 或 CALCULATETABLE 的过滤器参数时,它的行为完全不同:它从表中删除过滤器并且不返回表。

为了缓解 ALL 的这种令人困惑的行为,在 CALCULATE 内部使用 REMOVEFILTERS 时,引入了 REMOVEFILTERS 来替换 ALL。

想了解更多详情,你可以看看这篇文章。 https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/