Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

powerbi - DAX REMOVEFILTERS vs ALL

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.

Here goes sample data:

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"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

REMOVEFILTERS is just an alias of ALL here, so it works just the same.

Basically, ALL returns a table including all rows, ignoring any filters that might have been applied.

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.

To alleviate this confusing behavior of ALL, REMOVEFILTERS was introduced to replace ALL when it is used inside CALCULATE.

For more details, you may look at this article. https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...