Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

powerbi - Difference between CALCULATE(m, x=red) vs CALCULATE(m, KEEPFILTERS(x=red))

What is the difference between CALCULATE(m, x=red) and CALCULATE(m, KEEPFILTERS(x=red))

Apparently they are not the same. I found docs and explanation but I still do not get it.

https://docs.microsoft.com/en-us/dax/keepfilters-function-dax

https://dax.guide/keepfilters/

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Your first measure, without KEEPFILTERS overrides all other filters applied to field x.

The second measure, using KEEPFILTERS maintains the filter context on field x, and applies the new filter context as a subset of existing filters (or blank, if no overlap of filter contexts).

Here's a simple example PBIX file to demonstrate - play with the colour slicer, and see the difference in the two measures: https://pwrbi.com/so_57850298/

This SQLBI.com article explains it well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...