Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I have a question about using the CALCULATE() function.
I've made a measure using this function that I am using as part of a KPI card. However, that KPI card has filters on it. It seems that the measure I've created is ignoring those filters and only being parsed by the filters I've stated in CALCULATE(). How can I make it so that the value is filtered by both the CALCULATE function as well as the overarching context filters?
Thanks,
Farhan
Solved! Go to Solution.
@farhandsome
For the filter you use inside calculate function, wrap it in KEEPFILTERS, it will create and condition.
https://docs.microsoft.com/en-us/dax/keepfilters-function-dax
Example:
OnlyRed_KeepfiltersAll :=
CALCULATE (
[Sales Amount],
KEEPFILTERS (
FILTER (
ALL ( Products[Color] ),
Products[Color] = "Red"
)
)
)
________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@farhandsome
For the filter you use inside calculate function, wrap it in KEEPFILTERS, it will create and condition.
https://docs.microsoft.com/en-us/dax/keepfilters-function-dax
Example:
OnlyRed_KeepfiltersAll :=
CALCULATE (
[Sales Amount],
KEEPFILTERS (
FILTER (
ALL ( Products[Color] ),
Products[Color] = "Red"
)
)
)
________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@farhandsome
Yes, KEEPFILTERS will not overwrite, rather it adds to the existing filter and sort of itersects.
________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@farhandsome
Hope the explanation was clear? If so, accept the reply as a solution?
For further on this topic, refer to :https://www.sqlbi.com/articles/using-keepfilters-in-dax/
________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |