DAX 去除过滤器与所有 [英] DAX REMOVEFILTERS vs ALL

查看:18
本文介绍了DAX 去除过滤器与所有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将以下代码中的 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] )
)

据我所知,here 的提示是可能的.

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 的过滤器参数时,它的行为完全不同:它从表中删除过滤器并且不返回表.

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 去除过滤器与所有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆